Java Language for Selenium
Why Java for Selenium?
> Selenium written inward Java, it doesn't hateful that Java exclusively to a greater extent than compatible amongst selenium, nosotros tin give the sack utilization other supported languages also.
> Good back upward for Selenium amongst Java, You tin give the sack acquire to a greater extent than assistance documents too implementations from Internet.
> Majority of Selenium Testers(nearly 77%) using Java, too thus cognition sharing is rattling easy.
> Java is platform independent language, nosotros tin give the sack utilization it on whatever Operating environment.
How much Java is required for Selenium?
> Fore Test Automation using Selenium Core Java cognition is sufficient, Advanced Java non required.
> Java Basics too Object Oriented Concepts are required.
We tin give the sack segregate Java for Selenium into 2 categories.
A) Java Basics
B) Java Object Oriented Programming----------------------
1) Overview on Java
> Java Programming Language was developed past times Sunday Microsystems inward 1995, Now it is subsidiary of Oracle corporation.
> Java is an Object Oriented programming Language, In Java, everything is an Object. Java tin give the sack hold upward easily extended since it is based on the Object model.
> Java is a Platform independent Language. It tin give the sack hold upward compiled too interpreted.
> Java is Simple, It is slow to larn too implement.
> coffee is Securable, using Java nosotros tin give the sack prepare virus costless too tamper costless systems.
2) Java Environment Setup
We convey to setup coffee environs to write too execute Java programs, It varies from ane operating arrangement to another.
> If it is DOS (from Command prompt inward Windows), install coffee Software(JDK) too laid Environment variables.
> If it is Windows GUI, install Java too Eclipse(Java Editor) to write too execute Java programs
3) Java Syntax
> Java is example sensitive language(deference is at that topographic point inward betwixt upper too lower example letters)
Ex: Identifiers UFT too uft convey unlike pregnant inward java
> First alphabetic quality of a Class Name should hold upward inward upper case.
> Method names should kickoff amongst lower example letter
> Java Program file refer should just gibe amongst shape name.
> populace static void principal (String args[])- Java plan execution starts from principal method, which is mandatory inward every coffee program.
> Every declaration should halt amongst semi colon symbol.
4) Usage of Java
> Developing Desktop Applications (Ex: Acrobat Reader)
> Developing Web Applications
> Developing Enterprise Applications (ex: banking, Insurance Applications)
> developing mobile applications
> Embedded systems
> smart cards
> Games etc...
--------------------------------------------------
A) coffee Basics
1) Comments inward Java
Purpose of comments
> To brand the code readable
> To brand the Disable from execution
Java supports Single trouble comment too multiple lines comment.
2) Data Types inward Java
There are 2 categories of Data types inward Java
a) Primitive information types
b) Reference information types
3) Variables
a) Local variables
b) Instance variables
c) Class / Static variables
4) Java Modifiers
Modifiers are used to laid access levels for Classes, variables, methods etc...
a) Access Modifiers (Default, Public, Private, Protected)
b) Non-access Modifiers (Static, Final, Abstract, Synchronized)
5) Operators inward java
Operators are used to perform mathematical, comparing too logical operations.
Categories of operators:
a) Arithmetic
b) Relational operators
c) Bitwise operators
d) Logical operators
e) Assignment operators
f) Mise Operators
-------------------------------------------
6) Conditional statements
Used to insert verification points too for mistake handling.
Types of conditional statements inward Java:
a) If Statement
b) Switch statement
Types of Condition:
a) Single condition
b) Compound conditions
c) Nested conditions
Usage of conditional statements:
a) Executing a block of statements when status is true.
b) Execute a block of statements when status is truthful otherwise execute roughly other block of statements.
c) Decide amid several alternates (Else if)
d) Executing a block of statements when to a greater extent than than ane status is true.(Nested if)
e) Decide amid several alternates (Switch statement)
------------------------------------------
7) Loop statements
used for repetitive execution.
Types of Loop Statements
a) For Loop
b) While Loop
c) Do...While Loop
d) Enhanced For Loop (mainly used for Arrays)
---------------------------------
8) Arrays inward Java
Generally, Array is a collection of similar type of elements.
In Java, Array is an object that contains elements of similar information types.
Java Array is index based, index starts from zero.
The length of an Array is established when the Array is created too Array length is fixed.
Each item inward an Array is called an Element.
Declaration of Arrays
Assigning values to elements
Advantages too Disadvantages of Arrays.
-----------------------------------
9) Java Methods
Methods are likewise known equally procedures or functions
A Java method is a collection of statements that are grouped together to perform an operation.
Ex:
System.out.println
If you lot telephone phone the method, the arrangement genuinely executes several statements, inward social club to display a message on the console.
We tin give the sack practise methods amongst or without returning whatever value.
Basically Methods are 2 types
a) Built-in or pre-defined
Number Methods
Character methods
String methods
Date & Time Methods
Etc...
b) User defined
Method amongst returning value
Method without returning whatever value
-------------------------------------------------
10) Regular Expressions
It is a formula for matching patterns, H5N1 Regular aspect defines search pattern for strings.
Java provides the java.util.regex bundle for pattern matching amongst regular expressions.
--------------------------------------------------------
11) File too I/O operations inward Java.
The java.io bundle contains classes to perform input too output (I/O) operations inward Java.
Reading using input devices
Displaying on the console
Reading too writing text files
Working amongst Excel files.
---------------------------------------------------------
12) Exception treatment inward Java
In Computer programming, Exception is an abnormal condition.
An exception is an termination that occurs during the execution of a plan that disrupts the normal menstruum of instructions.
The exception treatment inward coffee is ane of the powerful machinery to grip the runtime errors too thus that normal menstruum of the application tin give the sack hold upward maintained.
----------------------------------------------------------
Java object oriented Programming
-------------------------------------
1) Class, Object, Method
In object oriented programming system(OOPS), nosotros designing a plan using Objects too classes.
Object:
It is an entity that has states too behaviors is known equally Object.
Ex: Pen, Chair, Table, Computer etc...
States / Properties of Dog object are color, height, weight etc... too behaviors moving, barking, jumping etc...
-------------------
Class:
Class is a template or pattern from amongst objects are created.
A Class a grouping of objects that has mutual properties.
----------------
Method: An functioning on Object.
--------------------------------------------
2) Inheritance
Inheritance is a machinery inward which ane object acquires all the properties too behaviors of rear object.
Using Inheritance nosotros tin give the sack practise classes that are built upon existing classes.
When nosotros Inherit from an existing class, nosotros tin give the sack reuse methods too fields from rear shape too nosotros tin give the sack add together novel methods too fields also.
Java Supports:
a) Single Inheritance
b) Multi marking Inheritance
c) Hierarchical Inheritance
Note: Java doesn't back upward Multiple Inheritance.
--------------------------------------------------------
3) Method Overloading too Overriding-------------------------------------
If a shape having multiple methods amongst same name, but unlike parameters is known equally method overloading.
Method overloading increases the readability of the program.
There are 2 ways to overload the method inward Java
a) past times changing publish of arguments
Ex:
add (int a, int b)
add (int a, int b, int c)
b) past times changing information types
Ex:
add (int a, int b)
add (char a, char b)
In Object Oriented programming overriding way to override the functionality of an existing method.
Method overriding provides a specific implementation of a method that is already provided past times its super shape (Parent class)
It is used for runtime polymorphism.
-------------------------------------------
4) Polymorphism
It is a concept past times which nosotros tin give the sack perform a unmarried inward unlike ways.
Polymorphism derived from 2 Greek give-and-take poly too morphs
Poly way -many
morphs way -forms / ways, too thus polymorphism way many forms.
we convey 2 types of Polymorphism inward java
a) Compile fourth dimension polymorphism
b) Runtime polymorphism.
We tin give the sack perform polymorphism inward coffee past times method overloading too method overriding.
--------------------------------------------------
5) Abstraction
Abstraction is a physical care for of hiding the implementation details too showing functionality to the user.
Another way, it shows of import things to the user too hides internal details.
Ex: Sending email
you merely type the e-mail too send, you lot don't internal physical care for of the e-mail delivery.
Abstraction focuses on what the object does instead of how it does.
In 2 ways nosotros tin give the sack accomplish Abstraction
a) Abstract Class (0 to 100%)
b) Interface (100%)
--------------------------------------------------
6) Encapsulation
Encapsulation is ane of the 4 cardinal oops concepts, other 3 are Inheritance, Polymorphism too Abstraction.
Encapsulation is a physical care for of wrapping code too information together into a unmarried unit.
Ex: Capsule (mixed of several medicines)
It provides the command over the data, suppose nosotros desire to value of the id greater than 100 only, nosotros tin give the sack write the logic within the setter method.
------------------------------------------------------
7) Java packages
A Java bundle is a grouping of similar type of classes, interfaces too sub-packages.
There are 2 types of coffee packages
a) Built inward packages
Ex: io, util, sql etc...
b) User defined packages
----------------------------------------------
8) Interfaces inward Java
An interface is a collection of abstract methods.
An interface is non a class, writing an interface is similar to writing a class, but 2 are unlike concepts.
------------------------------------------------------
Also Read:
Overview on Selenium
Selenium online Training
Sumber http://www.gcreddy.com/
Why Java for Selenium?
> Selenium written inward Java, it doesn't hateful that Java exclusively to a greater extent than compatible amongst selenium, nosotros tin give the sack utilization other supported languages also.
> Good back upward for Selenium amongst Java, You tin give the sack acquire to a greater extent than assistance documents too implementations from Internet.
> Majority of Selenium Testers(nearly 77%) using Java, too thus cognition sharing is rattling easy.
> Java is platform independent language, nosotros tin give the sack utilization it on whatever Operating environment.
How much Java is required for Selenium?
> Fore Test Automation using Selenium Core Java cognition is sufficient, Advanced Java non required.
> Java Basics too Object Oriented Concepts are required.
We tin give the sack segregate Java for Selenium into 2 categories.
A) Java Basics
B) Java Object Oriented Programming----------------------
1) Overview on Java
> Java Programming Language was developed past times Sunday Microsystems inward 1995, Now it is subsidiary of Oracle corporation.
> Java is an Object Oriented programming Language, In Java, everything is an Object. Java tin give the sack hold upward easily extended since it is based on the Object model.
> Java is a Platform independent Language. It tin give the sack hold upward compiled too interpreted.
> Java is Simple, It is slow to larn too implement.
> coffee is Securable, using Java nosotros tin give the sack prepare virus costless too tamper costless systems.
2) Java Environment Setup
We convey to setup coffee environs to write too execute Java programs, It varies from ane operating arrangement to another.
> If it is DOS (from Command prompt inward Windows), install coffee Software(JDK) too laid Environment variables.
> If it is Windows GUI, install Java too Eclipse(Java Editor) to write too execute Java programs
3) Java Syntax
> Java is example sensitive language(deference is at that topographic point inward betwixt upper too lower example letters)
Ex: Identifiers UFT too uft convey unlike pregnant inward java
> First alphabetic quality of a Class Name should hold upward inward upper case.
> Method names should kickoff amongst lower example letter
> Java Program file refer should just gibe amongst shape name.
> populace static void principal (String args[])- Java plan execution starts from principal method, which is mandatory inward every coffee program.
> Every declaration should halt amongst semi colon symbol.
4) Usage of Java
> Developing Desktop Applications (Ex: Acrobat Reader)
> Developing Web Applications
> Developing Enterprise Applications (ex: banking, Insurance Applications)
> developing mobile applications
> Embedded systems
> smart cards
> Games etc...
--------------------------------------------------
A) coffee Basics
1) Comments inward Java
Purpose of comments
> To brand the code readable
> To brand the Disable from execution
Java supports Single trouble comment too multiple lines comment.
2) Data Types inward Java
There are 2 categories of Data types inward Java
a) Primitive information types
b) Reference information types
3) Variables
a) Local variables
b) Instance variables
c) Class / Static variables
4) Java Modifiers
Modifiers are used to laid access levels for Classes, variables, methods etc...
a) Access Modifiers (Default, Public, Private, Protected)
b) Non-access Modifiers (Static, Final, Abstract, Synchronized)
5) Operators inward java
Operators are used to perform mathematical, comparing too logical operations.
Categories of operators:
a) Arithmetic
b) Relational operators
c) Bitwise operators
d) Logical operators
e) Assignment operators
f) Mise Operators
-------------------------------------------
6) Conditional statements
Used to insert verification points too for mistake handling.
Types of conditional statements inward Java:
a) If Statement
b) Switch statement
Types of Condition:
a) Single condition
b) Compound conditions
c) Nested conditions
Usage of conditional statements:
a) Executing a block of statements when status is true.
b) Execute a block of statements when status is truthful otherwise execute roughly other block of statements.
c) Decide amid several alternates (Else if)
d) Executing a block of statements when to a greater extent than than ane status is true.(Nested if)
e) Decide amid several alternates (Switch statement)
------------------------------------------
7) Loop statements
used for repetitive execution.
Types of Loop Statements
a) For Loop
b) While Loop
c) Do...While Loop
d) Enhanced For Loop (mainly used for Arrays)
---------------------------------
8) Arrays inward Java
Generally, Array is a collection of similar type of elements.
In Java, Array is an object that contains elements of similar information types.
Java Array is index based, index starts from zero.
The length of an Array is established when the Array is created too Array length is fixed.
Each item inward an Array is called an Element.
Declaration of Arrays
Assigning values to elements
Advantages too Disadvantages of Arrays.
-----------------------------------
9) Java Methods
Methods are likewise known equally procedures or functions
A Java method is a collection of statements that are grouped together to perform an operation.
Ex:
System.out.println
If you lot telephone phone the method, the arrangement genuinely executes several statements, inward social club to display a message on the console.
We tin give the sack practise methods amongst or without returning whatever value.
Basically Methods are 2 types
a) Built-in or pre-defined
Number Methods
Character methods
String methods
Date & Time Methods
Etc...
b) User defined
Method amongst returning value
Method without returning whatever value
-------------------------------------------------
10) Regular Expressions
It is a formula for matching patterns, H5N1 Regular aspect defines search pattern for strings.
Java provides the java.util.regex bundle for pattern matching amongst regular expressions.
--------------------------------------------------------
11) File too I/O operations inward Java.
The java.io bundle contains classes to perform input too output (I/O) operations inward Java.
Reading using input devices
Displaying on the console
Reading too writing text files
Working amongst Excel files.
---------------------------------------------------------
12) Exception treatment inward Java
In Computer programming, Exception is an abnormal condition.
An exception is an termination that occurs during the execution of a plan that disrupts the normal menstruum of instructions.
The exception treatment inward coffee is ane of the powerful machinery to grip the runtime errors too thus that normal menstruum of the application tin give the sack hold upward maintained.
----------------------------------------------------------
Java object oriented Programming
-------------------------------------
1) Class, Object, Method
In object oriented programming system(OOPS), nosotros designing a plan using Objects too classes.
Object:
It is an entity that has states too behaviors is known equally Object.
Ex: Pen, Chair, Table, Computer etc...
States / Properties of Dog object are color, height, weight etc... too behaviors moving, barking, jumping etc...
-------------------
Class:
Class is a template or pattern from amongst objects are created.
A Class a grouping of objects that has mutual properties.
----------------
Method: An functioning on Object.
--------------------------------------------
2) Inheritance
Inheritance is a machinery inward which ane object acquires all the properties too behaviors of rear object.
Using Inheritance nosotros tin give the sack practise classes that are built upon existing classes.
When nosotros Inherit from an existing class, nosotros tin give the sack reuse methods too fields from rear shape too nosotros tin give the sack add together novel methods too fields also.
Java Supports:
a) Single Inheritance
b) Multi marking Inheritance
c) Hierarchical Inheritance
Note: Java doesn't back upward Multiple Inheritance.
--------------------------------------------------------
3) Method Overloading too Overriding-------------------------------------
If a shape having multiple methods amongst same name, but unlike parameters is known equally method overloading.
Method overloading increases the readability of the program.
There are 2 ways to overload the method inward Java
a) past times changing publish of arguments
Ex:
add (int a, int b)
add (int a, int b, int c)
b) past times changing information types
Ex:
add (int a, int b)
add (char a, char b)
In Object Oriented programming overriding way to override the functionality of an existing method.
Method overriding provides a specific implementation of a method that is already provided past times its super shape (Parent class)
It is used for runtime polymorphism.
-------------------------------------------
4) Polymorphism
It is a concept past times which nosotros tin give the sack perform a unmarried inward unlike ways.
Polymorphism derived from 2 Greek give-and-take poly too morphs
Poly way -many
morphs way -forms / ways, too thus polymorphism way many forms.
we convey 2 types of Polymorphism inward java
a) Compile fourth dimension polymorphism
b) Runtime polymorphism.
We tin give the sack perform polymorphism inward coffee past times method overloading too method overriding.
--------------------------------------------------
5) Abstraction
Abstraction is a physical care for of hiding the implementation details too showing functionality to the user.
Another way, it shows of import things to the user too hides internal details.
Ex: Sending email
you merely type the e-mail too send, you lot don't internal physical care for of the e-mail delivery.
Abstraction focuses on what the object does instead of how it does.
In 2 ways nosotros tin give the sack accomplish Abstraction
a) Abstract Class (0 to 100%)
b) Interface (100%)
--------------------------------------------------
6) Encapsulation
Encapsulation is ane of the 4 cardinal oops concepts, other 3 are Inheritance, Polymorphism too Abstraction.
Encapsulation is a physical care for of wrapping code too information together into a unmarried unit.
Ex: Capsule (mixed of several medicines)
It provides the command over the data, suppose nosotros desire to value of the id greater than 100 only, nosotros tin give the sack write the logic within the setter method.
------------------------------------------------------
7) Java packages
A Java bundle is a grouping of similar type of classes, interfaces too sub-packages.
There are 2 types of coffee packages
a) Built inward packages
Ex: io, util, sql etc...
b) User defined packages
----------------------------------------------
8) Interfaces inward Java
An interface is a collection of abstract methods.
An interface is non a class, writing an interface is similar to writing a class, but 2 are unlike concepts.
------------------------------------------------------
Also Read:
Overview on Selenium
Selenium online Training