Usage of Java in Selenium

Usage of Java in Selenium

Usage of Java Programming in Selenium

Java is a general purpose programming language as well as Software platform.

Java as Programming Language – To develop Software Applications (JDK include JRE, JVM)

Java as Software Platform – To provide Run-time Environment (JRE include JVM))

Java has 3 Important Parts / 3 Important Editions

1) Java Standard Edition / Core Java (Old Name J2SE)

2) Java Enterprise Edition / Advanced Java (Old Name J2EE)

3) Java Micro Edition (Old name J2ME)

1) Java Standard Edition / Core Java

For Test Automation with Selenium, Core Java/Java Standard edition is sufficient, Advanced Java is not required.

Java Standard Edition / Core Java for Selenium

First, Java Environment Setup (To Create and Execute Java Programs/Test Scripts)

Manual Testing – Test Case

UFT/QTP – Test / Test Script

Selenium – Test Case / Test Script

1) Comments

We write comments in Selenium Test Cases,

Use of Comments in Selenium:
i) To write Test Case headers
ii) To write Method headers
iii) To explain complex logic

2) Data Types

Data Types are used in Test Automation for storing and comparing specific type of data.

3) Modifiers

Access Modifiers are used in Selenium Test Cases to define access levels for Variables, methods etc… But most of the Time we use public access modifier only.
Non-Access Modifiers static, final etc… are used in our selenium Test Cases.

4) Variables

We use Variables in our Selenium Test Cases for storing and handling data.

5) Operators

We use Operators in Selenium Test Cases for performing Arithmetic, Comparison, and Logical Operations.

6) Control Flow Statements

i) Conditional Statements
ii) Looping Statements
iii) Branching Statements

We use Conditional Statements in our Test Cases for inserting Verification Points, and for Error handling.

We use Looping Statements in our Selenium Test Cases for repetitive execution(Ex: Data Driven Testing).

7) Arrays

We use Arrays in our Test cases for handling Excel file like Table format Data.

8) Strings

Strings are more important for our Test Automation, whenever we read data from files and from Application objects then Computer program considers the data as String type data.

9) Input and Output Operations

We use Input for providing data for captcha (verification code) fields in our Test Cases.
We use Output statements to display output on the Console.

10) File Handling

We use Text Files or Excel files as resource for Data driven Testing.

11) Methods

i) Predefined Methods
ii) User defined Methods

We use Predefined methods to perform operations on Strings, Numbers, Arrays, Characters, Date and Time etc…

12) Exception Handling

Exception Handling is an important task in our Selenium Test Cases to handle Run-time errors.

Java OOPS (Object Oriented programming System)

1) Inheritance

Inheritance feature is limited use in selenium, We inherit (reuse) Methods/Components in our Test cases (From one Java Class to another)

2) Polymorphism

Some times we use Method OverLoading and Method Overriding features in our test Cases, but limited use.

Ex: We create two or more methods with same name for easy maintenance.

3) Abstraction

Abstraction feature is not used in our selenium, usually developers use this feature.

4) Encapsulation

Encapsulation feature is not used in Selenium, Usually developers use this feature for accessing private fields via public methods.

Also Read:

Java Step by Step Videos

Selenium Step by Step Videos


You may also like...