Selenium Tutorial 3

Selenium Tutorial 3

Session 1: Overview on Test Automation
    a) Advantages and Disadvantages of Manual Testing
    b) Advantages and Disadvantages of Test Automation
    c) Types of Test Tools
    d) ATLM (Automation Test Life cycle Methodology)

Session 2: ) Overview on Selenium    
a) Introducing Selenium
    b) History of the Selenium Project
    c) Selenium License
    d) Selenium suite of tools
    e) Advantages of Selenium
    f) Disadvantages of Selenium
    g) Selenium Vs UFT
    h) Frameworks used in Selenium
    i) Choose Selenium Tools
    j) Configure Selenium

Session 3: Selenium Test Process    

    a) Test Planning
    b) Generating Basic Tests
    c) Enhancing Tests
    d) Running and Debugging Tests
    e) Analyzing Test Results and Reporting Defects

Session 4: Java for Selenium    

    a) Why java for selenium?
    b) How much Java is required for Selenium?
    c) Overview on Java
    d) Java Environment Setup
A) Java Basics
    1) Comments
    2) Data Types
    3) Variables
    4) Modifiers
    5) Operators
    6) Conditional statements
    7) Loop statements

Session 4: Java Language for Selenium Part-2

viii) Arrays in Java

Generally, Array is a collection of similar type of elements.

In Java, Array is an object that contains elements of similar data types.

Java Array is index based, index starts from zero.

The length of an Array is established when the Array is created and Array length is fixed.

Each item in an Array is called an Element.

Declaration of Arrays

Assigning values to elements

Advantages and Disadvantages of Arrays.
ix) Java Methods
Methods are also known as procedures or functions

A Java method is a collection of statements that are grouped together to perform an operation.



If you call the method, the system actually executes several statements, in order to display a message on the console.

We can create methods with or without returning any value.

Basically Methods are two types

a) Built-in or pre-defined    Number Methods
    Character methods
    String methods
    Date & Time Methods

b) User defined    Method with returning value
    Method without returning any value
x) Regular Expressions
It is a formula for matching patterns, A Regular expression defines search pattern for strings.

Java provides the java.util.regex package for pattern matching with regular expressions.
xi) File and I/O operations in Java.
The package contains classes to perform input and output (I/O) operations in Java.

Reading using input devices

Displaying on the console

Reading and writing text files

Working with Excel files.
xii) Exception handling in Java
In Computer programming, Exception is an abnormal condition.

An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.

The exception handling in java is one of the powerful mechanism to handle the runtime errors so that normal flow of the application can be maintained.
Java object oriented Programming
Class, Object, Method
In object oriented programming system(OOPS), we design a program using Objects and classes.


It is an entity that has states and behaviors is known as Object.

Ex: Pen, Chair, Table, Computer etc...

States / Properties of Dog object are color, height, weight etc... and behaviors moving, barking, jumping etc...

Class is a template or blueprint from with objects are created.

A Class a group of objects that has common properties.
Method: An operation on Object.
i) Inheritance
Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object.

Using Inheritance we can create classes that are built upon existing classes.

When we Inherit from an existing class, we can reuse methods and fields from parent class and we can add new methods and fields also.

Java Supports:

a) Single Inheritance

b) Multi level Inheritance

c) Hierarchical Inheritance

Note: Java doesn't support Multiple Inheritance.
ii) Polymorphism
If a class having multiple methods with same name, but different parameters is known as method overloading.

Method overloading increases the readability of the program.

There are two ways to overload the method in Java

a) by changing number of arguments
add (int a, int b)

add (int a, int b, int c)

b) by changing data types

add (int a, int b)
add (char a, char b)

In Object Oriented programming overriding means to override the functionality of an existing method.

Method overriding provides a specific implementation of a method that is already provided by its super class (Parent class)

It is used for runtime polymorphism.
It is a concept by which we can perform a single in different ways.

Polymorphism derived from two Greek word poly and morphs

Poly means -many
morphs means -forms / ways, so polymorphism means many forms.

we have two types of Polymorphism in java

a) Compile time polymorphism
b) Runtime polymorphism.

We can perform polymorphism in java by method overloading and method overriding.
iii) Abstraction
Abstraction is a process of hiding the implementation details and showing functionality to the user.

Another way, it shows important things to the user and hides internal details.

Ex: Sending email

you just type the email and send, you don't internal process of the email delivery.

Abstraction focuses on what the object does instead of how it does.

In two ways we can achieve Abstraction

a) Abstract Class (0 to 100%)

b) Interface (100%)
iv) Encapsulation
Encapsulation is one of the four fundamental oops concepts, other three are Inheritance, Polymorphism and Abstraction.

Encapsulation is a process of wrapping code and data together into a single unit.

Ex: Capsule (mixed of several medicines)

It provides the control over the data, suppose we want to value of the id greater than 100 only, we can write the logic inside the setter method.
Java packages
A Java package is a group of similar type of classes, interfaces and sub-packages.

There are two types of java packages

a) Built in packages

Ex: io, util, sql etc...

b) User defined packages

Interfaces in Java
An interface is a collection of abstract methods.

An interface is not a class, writing an interface is similar to writing a class, but two are different concepts.
Java for Selenium (Core Java)

A) Java Basics
    Comments, Data types, Variables, Constants, Operators, Conditional statements,
    Loop statements, Araays, Methods, Regular expressions, File and I/O operations, Exception handling.

B) Java Object Oriented Concepts
    Inheritance, Abstraction, Polymorphism, Encapsulation
    Method Overloading and Overriding.
Java Environment Setup, Java Program Structure/ JavaSyntax

A) Java Environment Setup

> Download Java (JDK) and Install

> Set Environment Variable (Path variable)

How to set (windows 7):

Select MyComputer and Right click

> Properties

> Advanced System Settings

> Environment Variables

> Select New in System Variables

> Enter Variable as Path

> Enter Jdk bin directory path (C:\Program Files\Java\jdk1.8.0_40\bin) in Value field

> Ok > OK >OK
Verify the Java Environment:
Launch command prompt

> Type Java (it provides details)

1) Download Java (JDK) software and Install

2) Set Environment Variable (Path variable) in order access Java from any directory in C Drive.

3) Verify the Java Environment setup using java or javac commands.
3 steps for writing and executing Java programs
1) Write Java program in Notepad (Editor)

2) Compile the program (It creates Class file)

Command prompt > Change to Program file directory

> Type javac Program (java is extension, javac is java command for compilation)

3) Run / execute the Program (Output)

> Type java space Program name
It provides output on the console
Java Sample Program:
public class Sample{

public static void main (String [] args){

System.out.println ("Hello Java World");




i) First letter of the class name should be upper case value

ii) Class name and program file name as to same.
Download Eclipse software and unzip

What is Eclipse (IDE-Integrated development environment)

It is a Platform to create and execute Java programs, Perl, Python, Ruby and PHP etc...

It provides Editor, Context help, help for syntax errors, Auto compilation and debugging.

Open Eclipse main folder

> Click Eclipse file

It launches Eclipse IDE
Create Java Project
    -> Create a Package
        -> Create Class / Interface
Java Program Structure / Java Syntax
1) Package declaration statement


package Saturday;

Note: Package is used to store and Organize Classes based on functionality.

It must be first in our Java Program

2) Import statements

Import statements are kept after the package statement

We can import Built in and User defined packages /Libraries



import is a keyword to import built in / user defined packages

java is Project

io is package

Console is a class in io package

It loads/imports all classes from io package

3) Class declaration statement

public class Sample {

public is access modifier

class keyword to declare a class

Sample - name of the Class

Selenium Tutorial 4


Post a Comment