Presentation is loading. Please wait.

Presentation is loading. Please wait.

Selenium WebDriver Web Test Tool Training

Similar presentations


Presentation on theme: "Selenium WebDriver Web Test Tool Training"— Presentation transcript:

1 Selenium WebDriver Web Test Tool Training
Portnov Computer School Selenium WebDriver Web Test Tool Training Test Automation For Web-Based Applications Presenter: Ellie Skobel

2 Day 1 Java Basics

3 Variables Instance Variables – Non static fields whose values are unique to each instance of a class (to each object) Class Variables - A field declared with the static modifier; there is exactly one copy of this variable in existence, regardless of the number of instances. (Additionally, the keyword “final” could be added to indicate that the value will never change)

4 Variables Local Variables - variables declared between the opening and closing braces of a method. (Local variables are only visible to the methods in which they are declared) Parameters – are values passed to methods (always classified as "variables" not "fields“)

5 Variable Naming Variable names are case-sensitive.
A variable's name can be any legal identifier (an unlimited-length sequence of Unicode letters and digits) Must beginning with a letter When choosing a name for your variables, use full words instead of cryptic abbreviations. This will make your code easier to read and understand

6 Variable Types All variables must first be declared before they can be used, this involves stating the variable's type and name A variable's data type determines the values it may contain, plus the operations that may be performed on it Java programming language supports 8 primitive data types: byte, short, int, long, float, double, boolean, char Additionally Java provides support for character strings via the java.lang.String class.

7 Variable Types Type Description byte
an 8-bit signed integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). short a 16-bit signed integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). int a 32-bit signed integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice long a 64-bit integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). float a single-precision 32-bit floating point. Use a float (instead of double) if you need to save memory . This data type should never be used for precise values, such as currency. double The double data type is a double-precision 64-bit floating point. For decimal values, this data type is generally the default choice. boolean The boolean data type has only two possible values: true and false. char a single 16-bit Unicode character

8 Arrays A container object that holds a fixed number of values of a single type The length of an array is established when the array is created After creation, its length is fixed int[] anArray; // declares an array of integers anArray = new int[10]; // allocates memory for 10 integers Shortcut syntax to create and initialize an array: int[] anArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

9 Equality and Relational Operators
For numbers == equal to != not equal to > greater than >= greater than or equal to < less than <= less than or equal to For Strings equals - Returns true if the argument is a String object that represents the same sequence of characters as the argument. compareTo - Returns an integer indicating whether this string is greater than (result is > 0), equal to (result is = 0), or less than (result is < 0) the argument. Example: String1.equals(string2); String1.compareTo(string2);

10 Enhanced for statement
Used to make your loops more compact and easy to read Syntax: for (holder: list) { } Example: int[] numbers = {1,2,3,4,5,6,7,8,9,10}; for (int item : numbers) { System.out.println("Count is: " + item); Used instead of: for (int i=1; i<11; i++) { … }

11 Creating Objects 3 Steps:
Declaration: The code set in bold are all variable declarations that associate a variable name with an object type. Instantiation: The new keyword is a Java operator that creates the object. Initialization: The new operator is followed by a call to a constructor, which initializes the new object.

12 Declaration To declare a reference variable, you write: type name;
Example: Bicycle blueBike; The value will be undetermined until an object is actually created and assigned to it Declaring a reference variable does not create an object!

13 Instantiation and Initialization
The new operator instantiates a class by allocating memory for a new object and returning a reference to that memory. The new operator invokes the object constructor. Example: new Bicycle() Assigning the reference returned by the new operator to a variable initializes the variable Example: blueBike = new Bicycle()

14 Referencing Object's Fields
Code that is outside the object's class must use an object reference followed by the dot (.) operator, followed by a simple field name Example: (assume that the field names are color and speed) Bicycle bike = new Bicycle(5, “blue”); System.out.print( “This bike is ” + bike.color); System.out.print( “The bike’s speed is ” + bike.speed + “mph!”); This bike is blue The bike’s speed is 5mph!

15 Referencing Object's Methods
Use an object reference followed by the dot (.) operator, followed by a simple method name Provide any required arguments to the method within enclosing parentheses If the method does not require any arguments, use empty parentheses. Example: (assume that the method names are accelerate and stop) Bicycle bike = new Bicycle(5, “blue”); bike.accelerate(2); bike.stop(); The bike’s speed is 7mph! The bike’s speed is 0mph!


Download ppt "Selenium WebDriver Web Test Tool Training"

Similar presentations


Ads by Google