Variable Types
sbyte |
8bit |
-128 to 127 |
byte |
8bit |
0 to 255 |
short |
16bit |
-32,768 to 32,767 |
ushort |
16bit |
0 to 65,535 |
int |
32bit |
-2,147,483,648 to 2,147,483,647 |
uint |
32bit |
0 to 4,294,967,295 |
long |
64bit |
-9,233,372,036,854,775,808 to 9,223,372,036,854,775,807 |
ulong |
64bit |
0 to 18,446,744,073,709,551,615 |
char |
16bit |
0 to 65535 |
float |
32bit |
-1.5 x 1045 to 3.4 x 1038 |
double |
64bit |
-5 x 10324 to 1.7 x 10308 |
decimal |
128bit |
-1028 to 7.9 x 1028 |
bool |
1 bit |
True or False |
Declare Variables
[type] [varName] = [value];
string word = "Hello";
int x = 42;
bool thing = true;
int y; // Initialize without defining
|
Selenium
FindElement() |
find element on current page, selects first element if multiple exist |
FindElements() |
find all elements on page (generally to add to list or array) |
Navigate() |
navigate browser to a location |
Hierarchy of Element Identifiers
Id |
Name |
ClassName |
CssSelector |
XPath |
Git Commands
commit |
save current version of your code |
push |
send all local commits to server |
fetch |
grab all commits from server |
merge |
update current branch to match server |
pull |
same as fetch and merge |
|
|
Arithmetic Operators
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Modulus / Remainder |
++ |
Increment |
-- |
Decrement |
Assignment operators
= |
Simple Assignment |
A = 10 |
+= |
Add and Assign |
A += 10 is similar to A = A + 10 |
-= |
Subtract and Assign |
A -= 10 is similar to A = A - 10 |
*= |
Multiply and Assign |
A = 10 is similar to A = A 10 |
/= |
Divide and Assign |
A /= 10 is similar to A = A / 10 |
Try
try |
for code that has a possibility to fail |
catch (Exception e) |
code that runs if the try failed |
finally |
code that runs regardless of try pass or fail |
Creating a Method
[privacy] [static?] [returnType] name
public static string helloWorld()
{
return "word";
}
private void login(string user, string pass)
{
driver.FindElement...
}
|
Method Return Types
[any data type] |
method must return that data type |
void |
method doesn't return anything |
Control Statements
if |
run the next code block if condition is true |
else if |
run if previous if condition was false and this condition is true |
else |
run if all previous conditions were false |
switch |
checks variable and runs a case that matches |
while loop |
run the next code block until condition is false |
do while loop |
same as while, but checks condition at the end and runs at least once |
for loop |
run code block for a set number of times |
foreach loop |
run code block for every object in a Collection (List, Dictionary, etc.) |
break |
break out of current code block |
continue |
stop current iteration of loop and start next iteration |
Relational operators
== |
Equal to |
A==B false |
!= |
Not Equal to |
A!=B true |
< |
Less than |
A<B true |
> |
Greater than |
A>B false |
<= |
Less than Equal to |
A<=B true if A=10,B=10 |
>= |
Greater than Equal to |
A>=B true if A=10,B=10 |
Logical operator
&& |
AND |
A&&B is true is both A and B are true |
|| |
OR |
A||B is true if either one is true |
!= |
NOT |
!(A&&B) if the result of A&&B is true then the end result will be false |
|