Вы находитесь на странице: 1из 116

1

AUTOMATION TESTING
Performing testing on the software application / product with the help of
automation tools is called Automation testing. Automation tools are divided into
3 types.

1. Functional testing tool


2. Test Management tool
3. Performance tool

Functional Testing tools:-

A tool which we are using to test the functionality of the application is called
functional testing tool.

Eg:- Selenium, QTP (Quicks test professional), Sills touch, RFT (Rational
functional tester)

Test Management Tools:-

A tool which we are using to manage the entire testing process is called test
management tools.

Eg:- QC(Quality Center), Burgrille, Jira etc.

Performance Tools:-

A tool which we are using to test the performance of the application is called
performance tools.

Eg:- Load Runner, Jmeter, Sills Performer etc.

Advantages of Automation Testing:-

Time saving by implementing automation testing we can save the time during
performing testing in a project

Eg: If we are executing 1 test case manually in 1 hour, same test case we can
able to execute in 5 minutes with help of automation tool.

Repeatability/Reusability: If we want to execute the same test case repeatedly


for multiple times, instead of going for manual testing we can go for automation
testing.
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
2

Reducing Resources: By implementing automation testing the resources will be


reducing to completed the testing in a project.

Accuracy: By implementing automation testing we can maintain the Quality


during performing testing in a project.

Reducing production defects: By implementing automation testing we can


maintain the Quality so, that automatically the defects will be reduces.

Disadvantages of Automation Testing:-

1. License cost of the automation tolls


2. Some automation tools will not support some technologies.
3. Technical knowledge is required

Scope of Automation Testing:-

1. Features that is important for the business.


2. Scenarios which have large amount of data.
3. Common functionalities across applications

Technical Feasibility:-

1. Extent to which business components are reused.


2. Complexity of test cases.
3. Ability to use the same test cases for cross browser testing.

SELENIUM
Selenium is the functional and regression testing tool which has developed by
Jason huggins and team in thought works in the year of 2004.

The original name of the Selenium was JSFT(Java Script Functional Tester).
Selenium supports multiple languages like Java, dotnet, PHP, rube, python, perl
scripting etc.

Advantages of Selenium:-

1. Selenium is the open source tool mainly used for functional regression
test tools.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
3

2. Selenium supports multiple browsers like IE, firefox, opera, chrome,


safari etc.
3. It supports multiple environments/platforms like windows, unix, linux etc
4. It supports multiple languages like java, dotnet, PHP, python, ruby, perl
etc. So that by knowing at least one language we can able to do work on
selenium.
5. It supports mobile applications/ Android applications.
6. It supports the built in frameworks called Junit & Test ng etc.
7. Parallel test script execution is possible in selenium.

Disadvantages of selenium:-

1. It supports only web based applications.


2. It supports multiple languages.
3. Lack of technical support

Selenium components/ Components of selenium:-

Selenium is the combination of four different components.

1. Selenium IDE
2. Selenium RC/Set-1
3. Selenium WD/Set-2
4. Selenium Grid(Test Execution)

:- Selenium IDE is the record & playback tool for web based
applications. This is the add in /plug in for firefox browser. That
means we can install the selenium IDE in firefox browser, launch
the IDE from firefox browser, design the scripts and executes the
scripts only in the firefox browser.

NOTE:- The pre-condition to install selenium IDE is “firefox browser” should


be installed.

Navigation to install selenium IDE:-

Open the firefox browser

Enter the URL(http://www.seleniumhq.org/download)

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
4

Click on enter

Click on download latest released version from add on, Mozilla.org link under
selenium IDE

Click on add to firefox button

Click on Install

Click on restart now

When we click on restart now, firefox browser will be restarting & selenium
IDE will be installing with firefox.

What is record & playback?

This is the one of the key functionality in selenium IDE. When the selenium
IDE is in recording mode> If we perform any action on the application, tool will
capture the actions and generates the scripts. When we click on play button tool
will perform the same actions in the application.

What is element?

Element is nothing but a component in application. This element we also calling


as objects.

Element locators:-

Locators are nothing but the identifications of the elements in application. Since
every product in the world is having some identifications, in the same way
every element in the application also is having some identifications. These
identifications we called as locators/ properties & valued/ attributes.
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
5

List of locators:-

1. ID
2. Name
3. Class
4. Tagname
5. Xpath
6. Link text
7. CSS(Cascade style sheets)
8. DOM(Document object model)

Firebug:- firebug is adding for firefox browser which we can use to see the list
of locators of the elements in a firefox browser. Before working with frirebug
we need to install firebug in firefox browser.

Navigation steps to install firebug:-

Open the firefox browser

Enter URL(https://addons.mozilla.org/en-us/firefox/addon/firebug/)

Click on enter

Click on add-to firefox

Click on install

Responsibility of the Automation tester in a project:-

The Responsibility of the automation tester in a project will be converting


manual test case into automation script.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
6

(Business Operation) (Validations)


S.No Description Expected Result
1. Enter Uid Ok button should be disabled
2. Enter Pwd Ok button should be enabled
3. Click on Ok User should be able to login

Selenium

Uid
OK disabled
Pwd
OK enabled
Click on Ok
Able to login

How Selenium will identify the elements in application:-

Selenium will identify the elements based on the locators. Every element in the
application is having list of locators. In these locators most of them are common
locators (default locators) and some of them are unique locators with the
common locators. It is difficult for the selenium to identify the elements and
with unique locators only selenium can easily identify the elements.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
7

Selenium IDE Commands:-

There are 3 different types of commands available in selenium IDE. These


commands are also called as selenese commands

1. Actions
2. Assertions
3. Accessers

Actions we are using actions to perform the business operations in selenium


IDE.

Actions:- Type:-

We are using this command to enter the value in a text box.

Syntax:

Command Target Value


Type Element locator Value/data
Select To select the value in list Value/data
box(element locator)

Click:- to click on the element in a application.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
8

Syntax

Command Target Value


Click Element locator

Check:- To select the check box / radio button in application

Syntax:

Command Target Value


Check Element locator -

Uncheck:- To unselect the check box in a application

Syntax:

Command Target Value


Uncheck Element locator -

Eg:- prepare the test script to enter email, pwd, select day, month

Type Id=email Kishore Click on create an


Type Id=pass 1234 account button in
Select Id=day 24 fb
Select Id=month Apr
Select Id=year 1994
Type Id=u-o-b 1234567890
click Id=u-o-j

Open:- To open the new application in a existing browser

Syntax

Command Target Value


Open URL -

Open Window:- To open the new application in a new browser.

Syntax

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
9

Command Target Value


Open Window URL -

Close:- To close the application

Syntax

Command Target Value


Close - -

Assertions:- We are using Assertions to perform the validations in selenium


IDE. Under Assertions we have 3 different types of commands.

1. Verify
2. Assert
3. Wait for

Note:- Which ever commands is available in verify, All those commands also
available in assert & wait for.

Verify:- we are using verify commands to perform validations, and tool


continues the execution, even validation true/false.

Command Target Value


Type Id=Name Ranjith
Verify text present Abcd If true / false
immediately if all
Click Id=ok Executes next command

Assert:- We are using assert commands to perform the validations. And tool
continues the execution only if the validation is true. If the validation is false
tool will stop the execution

Command Target Value


Type Id=name Ranjith
Assert verify text present Abcd Stop execution when if
click Id=ok false

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
10

Wait for: we are using wait for commands to perform the validations. And tool
continues the execution if the validation is true. Or it will stop the execution for
default time and continues the execution if the validation is false

Cmd Target Value


Type Id=name Ranjith
Waitfor text present Abcd If it is false it will take
Click Id=ok some default value after
words it will execute
next command

Text Present:- To verify whether the text is present in the application or not.

Syntax

Command Target Value


Verify text present
Assert text present Text
Wait for text present

Element present:- To verify whether the element is present in the application or


not.

Syntax

Command Target Value


Verify element present Element locator -
Assert element present Element locator -
Waitfor element present Element locators -

Checked:- To verify whether the click box or radio button is checked or not.

Syntax:

Command Target Value


Verify checked Element locators
Assert checked Element locators
Wait for checked Element locators

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
11

Editable: To verify the whether the element is editable or not

Syntax:

Command Target Value


Verify editable Element locator
Assert editable Element locator
Waitfor editable Element locator

Negative commands:-

1. Text not present


2. Element not present verify, assert & wait for
3. Not checked
4. Not editable etc

Accessors: we are using Accessors to perform the validations but tool will be
storing output into variable. That is the reason all the accessors commands start
with keyword called “store”

NOTE:-whichever the commands available in assertions, all the commands also


available in accessors.

NOTE:- Once we store the output into variable that variable value we can print
by using the command called “echo”.

Eg:-

Command Target Value


Type Id=email Ranjith
Store text present Always A
Echo ${a}
Type Id=pass sharanya

Store text present

To verify the text & store the o/p into variable.

Command Target Value

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
12

Store text present Text variable


Echo ${variable}

Store:- To store the value into variable

Syntax:

Command Target Value


Store Value Variable(a)
Type Id=email ${a}
Type Id=pass ${a}

Eg:-

Step No Description Expected Result


1. Enter email in facebook Password should be available and
application it should be editable
2. Enter password Login should not be available and
first name should be editable.
3. Enter first name Abcdef text should not present and
account text should be available.
4. Select the day as 24 Month should be available and
mail radio button should not be
checked
5. Launch yahoo mail User name should be available &
application in the same should not be editable.
browser

Script:-

Command Target Value


Type Id=email Sharanya
Verify element present Id=pass
Wait for editable Id=pass
Type Id=pass Abcdef
Wait for element not Id=u-o-m
present
Wait for editable Id=u-o-1
Type Id=i-o-1 Aravelli
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
13

Wait for text not present Abcdef


Wait for text present Account
Select Id=day 24
Wait for element present Id=month
Wait for not checked Id=u-o-f
Open http://
Wait for element present id=login-username
Wait for not editable id=login-username
Advantages of Selenium IDE:-

 We can design the scripts easily by using record and playback.


 We can execute the complete scripts/execute the individual steps alone.
 We can capture the locators of the elements using select option.
 We can convert recorded/ writing scripts into various formats like RC,
Webdriver etc.
 We can increase/ decrease the default time for execution.

Disadvantages of Selenium IDE:-

 It supports only firefox browser


 We cannot able to apply conditional statements like if, if else etc.
 We cannot apply looping statements like for loop, while loop etc.
 We cannot able parameterise the data (pass the data) into test script from
outside.
 We cannot able to implement the frameworks in selenium IDE.

CORE JAVA
JAVA is the object oriented programming language which has developed by
“SUN MICROSYSTEMS” & later on it was acquired by oracle. JAVA is the
secured and “platform independent” language which is using to develop the
online applications, secured applications online games etc.

What is Platform Independent?

JAVA is the platform independent because whichever the program we are


writing in one environment that we can run in another environments

How JAVA Works

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
14

We need to design JAVA program in notepad, save the file with .java extension
and then we need to compile the java file by using the command called javac.
When we compile the java file, compiler will create one class which contains
byte code, we need to execute the java class file by using the command called
java. When we execute JVM will be converting the byte code of the class file
into specific machine understandable format.

JDK 1.8 Class Abcd{ Byte code


Path & P s v m{ windows
Class path _____
____
____
} unix
}

linux

0628.java javac Abcd.class java abcd


0628.java execution

Navigation to setup path & class path

Install the JDK(it will be installing in c drive)

Right click on my computer

Propertied

Advanced system settings

Click on environment variables

Click on new button under user variable

Specify the variable name as path

Specify the variable value as bin location (C:/pgm files/java/jdk1.8.0-65/bin;)

Click on ok
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
15

Click on new button again

Specify the variable name as class path

Specify the variable value as lib location (C:/pgm files/java/jdk 1.8.0-5/lib;)

Click on ok

Click on ok

Click on ok

Structure of the java program

Package package Name;

Import statement ;(optional)

Class ClassName{

P S V M{

______

_______

________(statements)

JAVA is pure case sensitive language and strictly following the below naming
conventions.

Package:- package name should always contains lower case.

Eg:- package pack1

Package pack2 etc.

Class:- Class name should starts with upper case and first character of every
word in a class name should be upper case.

Eg:- class ClassOne

Class ClassOneTwo
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
16

Method:- Method/function should starts with lower case and first character of
second word onwards should be upper case.

Eg:- methodOne

methodOneTwo

NOTE:- method name, package name, class name should not contain spaces,
should start with alphabets and can contains numarics. If we are specifying the
public class in java pgm, the file name should be same as class name.

Statements:-

Operators in JAVA:-

We are using operators to perform the operations in a java program. We are


using 3 different types of operators in JAVA.

Arthematic operators:- We are using arthematic operators to perform the


mathematical operations like addition, subtraction, multiplication etc.

+ Addition, string concatenation


- Subtraction, negation
* Multiplication
/ Division
= Equal
++ Increment
-- decrement

Conditional Operators:- To check/ verify the conditions in a java pgm.


(Relational operators). These are giving Boolean results.

< Less than


> Greater than
<= Less than equal to
>= Greater equal
== Double equal
!= Not equal

Logical operators:- To perform the logical operations in a JAVA pgm.

&& AND (Any 1 condition false result false)


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
17

|| OR (Any 1 condition true result true)

Data types:- We are using data types to preserve space to the variables into
memory. That is the reason while creating the variables we should specify the
data type in JAVA so that based on the data type system allocates the space to
the variable into memory.

Based on the range there 8 different types of data types available in java.

Byte

Short

Int

Long

Double

Float

Char

Boolean

Output Statements in Java:-

A statement which we are using to get the output from the program is called
output statement. We are using two different types of o/p statements in java.

System.out.print

System.out.println

System.out.print:- We are using this statement to get all the o/p from the
program in a single line.

System.out.print(variable-“value”);

System.out.Println:- We are using this statement to get all the o/p from the
program in a line by line.

System.out.println(Variable/value);

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
18

Eg:

Class output{

Public static void main(String[] args)

Int a=10;

Int b= 20;

Int c=10*20;

Int d= b-a;

Int e=a+b;

s.o.p(c);

s.o.p(d); o/p: 2001030

s.o.p(e);

Class output

Public static void main

Int a=10;

Int b=20;

Int c=a*b;

Int d=b-1; o/p

s.o.pln(c); 200

s,o.pln(d); 20
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
19

Conditional statements:-

We are using conditional statements to check/verify the conditions in a JAVA


program.

There are four different types of conditional statements available in JAVA.

If condition

If else condition

If else if condition/nested if condition

Switch case

If :-

We are using if statement to check/verify the condition and will get the output
only when the condition is true. We will not get the o/p if the condition is false.

Syntax:- if (condition)

Statement;

Class conditional{

Public static void main{

Int a =30;

Int b=40;

If (a<b)

s.o.p(“A is less than B”);

O/P: A is less than B.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
20

Else:- We are using if else statement to check/verify the condition and will get
the output even though the condition is true/false.

Syntax:-

If (condition)

Statement 1;

Else

Statement 2;

Class conditional{

Public static void main(String[] args){

Int a=30;

Int b=40;

If (a<b)

s.o.p(“A is less than B”);

else

s.o.p(“A is less than B”);

O/P:- A is less than B

If else if condition:- We are using these statements to verify the condition and
tool will print the output if the condition is true or it will check the another
condition if the condition is false.

Syntax:-

If (condition1)

Statement 1;

Else
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
21

If(condition 2)

Statement 2;

Else

If (condition 3)

Statement 3;

Else

Statement 4;

Class conditional{

Public static void main(string[] args){

Int a=30;

Int b=40;

Int c=50;

If (a>b && a>c)

s.o.p(“A is greater”);

else

if(b>c)

s.o.p(“B is greater”);

else

s.o.p(“C is greater”);

O/P: C is greater

Switch case:- We are using this statements to verify multiple conditions at a


time in JAVA program.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
22

Syntax:

Switch variable/value{

Case condition 1:

Statement 1;

Break;

Case conditon2:

Statement 2;

Break;

Case condition 3:

Statement 3;

Break;

Default:

Statement default;

Break;

Eg:-

Class conditional{

Public static void main{

Int a=10;

Int b=6;

Int c=a-b;

Switch(c)

Case 1: s.o.p(“C value is 1”);

Break;
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
23

Case 2: s.o.p (“C value is 2”):

Break;

Case 3: s.o.p(“ C value is 3”):

Break;

Case 4: s.o.p(“C value is 4”);

Break;

Default:

s.o.p(“C value is in out of range”):

break;

} } O/P: C value is 4.

ECLIPSE
Eclipse is the IDE/ Editor for Java which we can use to design the java
programs and execute the programs. Like as eclipse we have a different editors
like net Beans, editplus, notepad++ etc but eclipse the popular editor for java>
Before working with eclipse we need to download it & create the java project.

Navigation steps:-

Install JDK

Down eclipse

Create one folder called java-practice on dp

Copy the eclipse & paste into practice folder

Double click on eclipse folder

Double click on eclipse icon(now we can see work space location window)

Specify the work space location(This is the location where all java programs
will be storing)

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
24

Click on ok

Click on work bench in welcome page of eclipse (Now we can navigate to home
page of eclipse)

Go to the file menu in eclipse home page

New project

Double click on java project

Specify the project name

Click on finish

When we click on finish java project will be creating in eclipse

Navigation to create java program in eclipse:-

Expand the (navigation) java project which we create

Right click on SRC(source)

New

Package

Specify the package name

Click on finish

Right click on package which we created

New

Class

Specify the class name

Select the main method check box

Click on ok

Looping statements:

We are using looping statements to execute the some code for multiple no of
times in a java program.
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
25

We are using 3 different looping statements in java

For loop

Nested for loop

While loop

For loop:- we are suing for loop to execute the same line of the code for specific
number of times.

Syntax:- for (initialization; condition; increment/decrement){

Eg:- package packone;

Public class first{

Public static void main{

Int i;

For (i=0;i<6;i++){
int a=30;

Int b=40;

Int c+a*b;

System.out.println(“c value is “ +c+”-“+i);

O/P:-

C value is 1200-1

C value is 1200-2

C value is 1200-3

C value is 1200-4

C value is 1200-5
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
26

Eg:-

Int i;

For (i=1;i<6;i++){

Int a=30;

Int b=40;

Int c=a X b;

System.out.println(“C value is “ +C+”-“+i);

I=i+1;

O/P;

C value is 1200-1

C value is 1200-3

C value is 1200-5

Nested for loop:-

In nested for loop we are inserting one for loop inside another for loop.
Execution starts always from main loop, it goes to sub loop, complete the sub
loop all the iterations then its come back to main loop

Syntax:for (initialization; condition; increment/decrement){

For (initialization;condition; increment/decrement){

Int i; o/p
Int j; 1-1
For (i=1;i<5;i++){ 1-2
For (j=1; j<4;j++){ 1-3
s.o.p(i+”-“+j); 2-1
} 2-2
} 2-3
3-1
3-2

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
27

3-3
4-1
4-2
4-3

While loop:-

We are using while loop to execute the same lines of the code until the
condition is satisfied.

Syntax:- initialization

While(condition){

Statement

Increment/decrement

String functions:-

We are using string functions to perform the string related validations in java.

Length:- we are using this variable to know the length of the string.

Syntax:- variable.length

Eg:-

Package packone

Public class strings{

Public static void main(string[] args){

String a=”1234 5678”;

If (a.length()==10)

System.out.println(“pass”);

Else

System.out.Println(“fail”);
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
28

Output:- pass

Startswith:- To verify whether the string is starting with specific character or


not.

Syntax:- variable.startswith(expected text)

Endswith:- To verify whether the variable is ending with specific characters or


not.

Syntax:- variable.endswith(expected text)

Example:- string a=”abc123456”;

If (a.startswith(“k”)==true)

System.out.println(“pass”);

Else

System.out.println(“fial”);

If(a.endswith(“6”)==true)

System.out.println(“pass”);

Else

System.out.println(“fail”);

Output:-fail

Pass

toLowerCase:- To convert uppercase into lower case

syntax:- variable.toLowerCase();

toUpperCase:- To convert lowercase into upper case

syntax:- variable.toUpperCase();

example:-string a=”ABCDEF”;
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
29

string b=”abcdef”;

System.out.println(a.toLowerCase());

System.out.Println(b.toUpperCase());

Output:-

Abcdef

ABCDEF

Equals:- To verify whether one string is equal to another string or not.

Syntax:- variable.equals(second/another variable)

EqualsIgnoreCase:- To verify whether one variable is same as another variable


or not irrespective of case.

Syntax:- variable.equalsIgnoreCase(another variable)

Example:- string a=”ABCDEF”;

String b=”abcdef”;

String c=”ABCdef”;

If(a.equals(b)==false)

System.out.println(“pass”);

Else

System.out.println(“fail”);

If(a.equlsIgnoreCase(b)==true)

System.out.println(“pass”);

Else

System.out.println(“fail”);

If(b.equalsIgnoreCase(c)==true)

System.out.println(“pass”);

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
30

Else

System.pit.println(“Fail”);

Output:- pass

Pass

Pass

Contains:-

To verify whether the string contains specific charcter or string or not.

Syntax:- package packone;

Public class strings{

String=”abcdef”;

If(a.contains(“d”0==true)

System.out.println(“pass”);

Else

System.out.println(“fail”);

Output:- pass

Example:- string a=”abcdef”;

String b=”XYZ1234”;

Sring c=”abcxy”;

1. Verify length of the variable should be greater than length of the c


variable should be less than length of the variable.
2. A variable should not be same as b variable and c variable
3. C variable should be same as a variable irrespective of the case.
4. A variable should contains cd and should not contains xy

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
31

5. Convert b variable into uppercase and verify it should contains z &


should not contains z

Package packone;

Public class strings{

Public static void main(string[] args)

String a=”abcdef”;

String b=”XYZ1234”;

String c=”abcxy”;

If(a.length()>c.length() && a.length()<b.length())

System.out.println(“pass”);

Else

System.out.println(“fail”);

If (a.equals(b)==false && a.equals(c)==false)

System.out.println(“pass”);

Else

System.out.println(“fail”);

If(c.equlsIgnoreCase(a)==true)

System.out.println(“pass”);

Else

System.out.println(“fail”);

If(a.contains(“cd”)==true&&a.contains(“xy”)!=true)

System.out.println(“pass”);

Else

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
32

System.out.println(“fail”);

If(b.toUpperCase()==true.b.contains(“z”)==true && b.contains(“z”)!=true)

System.out.println(“pass”);

Else

System.out.println(“fail”);

Concate:- To concatenate with string with another string

Syntax:- package packone;

Public class strings{

Public static void main(string[] args){

String a=”abcdef”;

String b=”XYZ1234”;

String c=”abcxy”;

System.out.println(a.concat(b).concat(c));

Output:- abcdefxyz1234abcxy

CharAt:- To verify which character si available in which index in the string

Syntax:- variable.CharAT(index no)

Note:- index number starts with zero.

Example:- package packone;

Public class strings{

Public static void main(string[] args){


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
33

String a =”abcdef”;

System.out.println(a.charAt(4));

}}
output:-e

Indexof:- To verify which character is available in which index.

Syntax:- package packone;

Public class strings{

Public static void main(string[] args){

String a =”abcdef”;

System.out.println(a.indexof(“b”));

Output:- 1

Trim:- We are using this function to eliminate starting and ending spaces of the
string

Syntax:- variable.trim()

Example:- package packone;

Public class strings{

Public static void main()(string[] args){

String a=” abc 123 ; “

System.out.println(a.lenth());

String b=a.trim();

System.out.println(b);

System.out.println(b.length());

}
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
34

Output:- 18

10

Replace:- To replace old character with new characters in a string

Syntax:- var.replace(“old character”, “new character”)

Public class strings{

String a =” abc 123 “;

System.out.println(a.replace(“ “, “ “));

Output:-

Split:- to split the variable into multiple strings

Syntax:- variable. Split(“separactor”);

Public class strings {

Public static void main(string[] args){

String a=”abcd 123 4567 111 XYZ1 22”;

String[] b=a.split(“ “);

Int i;

For (i=0; i<b.length;i++)

{
if(b[i].length()==3)

System.out.println(b[i]);

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
35

Output:- string a=”123 456 678 321 999 asd”;

String[] b=a.split(“ “);

System.out.println(b[1].length());

System.out.println(b[2]);

System.out.println(b[0]);

String a=”abcd XYZ 123456 klmDOP@;

String b=”klmnop abc1234 ABCD”;

STRING C=”123456 ABCD klmnop”;

1.split all the 3 variables into multiple strings

2. Number of strings in a variable should be greater than number of strings in b


variable & c variable.

3. first string of the a variable should be same as last string of the b variable &
second string of the c variable irrespective of the case.

4. length of the first string of the b variable should be greater than last string of
the b variable and should be same as last string of the c variable.

5. Last string of the c variable should contains m or z.

6. verify fourth character in a first string of b variable should be o and second


character should not be k.

7. second string in a variable should starts with x and should ends with z.

Commenting in java:- We are using commenting not to execute specific lines of


the code in a java program and to provide additional information in a java
program.

For applying commenting for single line of the code we are using “//”

For applying commenting for for group of statements “/* */”


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
36

Variables in Java:- We are using variables to store the values which we can
reuse them for multiple times. There are 3 different types of variables available
in java.

Local variables

Static variables

Non-static variables/ instant variables

Local variables:- Local variables are the variables which we are creating inside
the method/block and the scope of the local variable is only within the method.
That means when we close the method, automatically the usage of the local
variable also will be closed.

Example:- package sample{

Public class var{

Public static void a1(){

Local variables

Int a=30; int b=40;

System.out.println(a*b);

Public static void b1(){

Local variables

Int a=30; int b=40;

System.out.println(a+b);

Public static void main(string[] args){

a1();

b1();

}
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
37

Output:-1200

70

Static variables:- static variables are the variables which we are creating inside
the class and these variables are loading while class is laoded. These static
variables we can access directly within the class, classname. Variable name in
different class, class name. Variable name in different package but make sure
that variable should be public.

Example:

Pckage p1;

Public class Abc{

Public static int a=30;

Public static int b=40;

Public static void main(string[] args){

System.out.println(a*b);

Public class XYZ{

Public static void main(string[] args)

System.out.println(Abc.a*Abc.b);

Package p2;

Import p1.Abc;

Public class klm{

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
38

Public static void main(string[]args)

{
system.out.println(Abc.a*Abc.b);

Same class Different class Different


package

Static Directly Classname.variablename Class


name.variable
name(public)
Non-static Object Object Object(Public)

Non-static variables:- non-static variables are creating inside the class and these
variables are loading while object creation.

Example:- (same class)

Package packone;

Public class var{

//creating non-static variables

Public int a=30;

Public int b=40;

Public static void main(string[] args){

//creating object

Var v =new var();

//Accessing non-static variables

System.out.println(v.a*v.b)

Output:- 1200

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
39

(different class)

Package packone;

Public class var1{

Public static void main(string[] args){

// creating object

Var v = new var();

//Accessing non-static variables

System.out.println(v.a+v.b);

Output:- 70

(different package)

Package packtwo;

Import packone.var;

Public class var2{

Public static void main(string[]args){

//creating object

Var v=new var();

//Accessing non-static variables

System.out.println(v.a*v.b);

Output:- 1200

ACCESS SPECIFIERS
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
40

Access specifiers allowing variables are using to give the access permissions to
variables, methods, constructors and classes

There are 4 different access specifiers available in java

Public

Private

Protected

Default

Public:- with this we can access variables and methods across the globe(same
class, different class, different package)

Protected-with this we can access variables and methods within the package.

Private:- with this we can access variables and methods only with in the class.

Default:- with this we can access variables and methods within the same
package.

Same class Different class Different package


Public
Private X X
Protected X
Default X

(Same class)

Package packone;

Public class Access{

Public static int 1=20;

Protected static int b=40;

Private static int c=50;

Static int d=60;

Public static void main(string[] args){


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
41

System.out.println(Access.a* Access.b*Access.c*Access.d);

Output:-(Different class)

Package packone;

Public class Access1{

Public static void main(string[] args){


system.out.println(Access.a* Access.b*Access.d);

Output:- (different package)

Package packtwo;

Import packone.Access;

Public class Access2{

Public static void main(string[] args){

System.out.println(Access.a);

Output:-

Methods:-

A group of statements, set of logic which we can reuse for multiple times.

If any logic is reusable for multiple times, we are identifying that logic make it
as method or function. Here after whenever we require that logic, instead of
writing that logic again and again simply we are calling the methods.

There are 2 different methods available in java


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
42

1. Static method
2. Non-static method

Static methods:-

Static methods are loading while class is loading and we can access these
methods directly within the class, class name. Method name in different class.

Non-static methods:-

Non-static methods are loading while object is loading, so that non-static


methods we can access only by creating the object.

Example:- package packone;

Public class methods{

//creating static methods

Public static void a1(){

System.out.println(“This is static method”);

//creating non static methods

Public void b1(){

System.out.println(“This is non-static method”);}

Public static void main(string[] args)

//Accessing static method

a1();

//Accessing non-static method

Methods m=new methods();

m.b1();

Output:- This is static method


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
43

This is non-static method

Methods with arguments:-

Sometimes we need to execute the same methods multiple times with different
data. In that case we are creating methods with arguments so that while
accessing the methods we can pass the data into methods through arguments.

Example:-

Package packone;

Public class method{

Public static void a1(int a, int b, int c){

System.out.println(a*b*c);

Public static void main(string[] args){

a1(10,20,30);

a1(40,50,60);

a1(70,80,90);

Output:- 6000

1,20,000

5,04,000

Constructors in Java:-

Constructors are similar to methods which is loading while creating the object
with the help of constructors we can pass the data into the methods through
objects.

Standards to follow while creating constructors:-

Constructor name should be same as class name.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
44

Constructor should not contains any return type

If we are not creating any constructor in a class by default compiler will create
default constructor.

One class can contains any number of constructors. All the constructors should
be same as class name but with different arguments.

(constructor overloading)

There are two different types of constructors available in java.

1. Constructor without having arguments(default constructors)


2. Constructor with having arguments

Constructors without having arguments:

Sometimes we creating objects without having arguments in that case while


accessing the constructor also we need not to pass the arguments.

Example:- package packone;

Public class const{

//creating constructor

Const(){

System.out.println(“This is constructor”);

//creating method

Void a1(){

System.out.println(“This is method”);

Public static void main(string[] args){

Const c =new const();

c.a1();

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
45

Output:- This is constructor

This is method

Constructors with having arguments:-

Usually we are creating multiple constructors in a class with different


arguments. While creating the constructors we need to pass the arguments into
objects.

Example:-

Package packone;

Public class Button{

Int height; int width; string name;

//creating constructor

Button(int h, int w, string n){

Height=h;

Width=w;

Name=n;

Button(int k, int l){

Height=k;

Width=l;

//creating method

Void buttoncreation(){

System.out.println(“Button created with height, width, name as +h+”-“+2+”-


“+n);}
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
46

Void emptyButton(){

System.out.println(“Button created with height, width as +h+”-“+w+”-“);}

Public static void main(string[] args){

Button ok=new Button(40,40,”ok”);

Ok.buttonCreation();

Button Cancel1=new Button(50,50,”Cancel”);

Cancel.ButtonCreation();

Button empty1=new Button(60,30);

Empty1.emptybutton();

Example2:-

Package packone;

Public class SampleConst{

Int a; int b; int c;

SampleConst(int k, int l, int m){

A=k; b=l; c=m;}

SampleConst(int x, int y){

A=x; b=y;}

SampleConst(int d){

C=d;}

Void multiply(){

System.out.println(a*b*c);}

Void addition(){
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
47

System.out.println(a+b);

Void square(){

System.out.println(a*a);

Public static void main(string[] args){

SampleConst s=new SampleConst(20,30.40);

s.multiply();

SampleConst s1=new SampleConst(30);

S1.square();

SampleConst s2=new SampleConst(40,50);

S2.addition();

Class:-

Class is the collection of variables and methods.

This variables and methods we called as the members of the class. These
members might be static members or non-static members or both.

Example:- package packone;

Public class ClassClass{

//creating variables

Int a =30;

//creating methods

Void a1(){

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
48

System.out.println(“This is method”);

Object:-

Objects are the instances of the class that means if you want to access the
instance members of the class we need to create the reference object. So that
with the help of object we can access instance members.

Syntax:- package packone;

Public class ClassClass{

//creating variables

Int a=30;

//creating methods

Voida1(){

System.out.println(“This is method”);

Public static void main(string[] args){

ClassClass c=new ClassClass();

System.out.println(c.a*c.a);

c.a1();

Package:- Packages are the collection of classes and interfaces. There are 2
different packages available in java.

1. User defined package


2. Built in package

User defined package:-

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
49

User defined packages created by user and reusing for multiple times.

Built in package:-

Built in packages are the packages which are created by vendor and reusing for
multiple time.

Note:- The default package in java is java.lang.

Java API Selenium server.jar

Java.io Com.thoughtworks.selenium
File input string Default selenium
Open();
Close(); Start();
File output string Open();
Create(); Close();
Available(); Create();
File
Start();

Ecllipse

Java project

Package packtwothree

Import java.io.fileinputstring

Public class Abcd{

Public static void main{

Fileinputstring f=new fileinputstring();

f.open();

f.close();

fileoutputstring f0=new fileoutputstring();

f0.create();

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
50

f0.available();

Same class Different package


Package packone; Package packtwo;
Public class Abc{ Import packone.Abc;
Public void a1(){ Public class klm{
Sopln(“This is method”);} P s v m{
Public static void main(string[] args){ Abc.a=new Abc();
Abc a =new Abc(); a.a1();
a.a1(); }

SELENIUM REMOTE CONTROL


Selenium RC is the server which we can use to design the test scripts and
execute the test scripts in different browsers. Before working with selenium RC
we need to configure selenium standalone server.jar file with eclipse.

Navigation for configuring selenium server with eclipse.

Install the JDK

Download the eclipse

Download selenium server stanalsone2.44.jar from the below location

https://selenum.release.storage.googleapis.com/index.html?path-2.44/

create one folder called selenium on desktop

copy the eclipse and paste into it

create one folder called jars under selenium

copy the selenium server jar into jars folder

open the eclipse

double click on eclipse icon

provide the work space location

click on ok
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
51

click on work bench

goto the file menu in eclipse

new

project

double click on java project

specify the project name

click on finish

expand the java project which we created

Right click on JRE system library

Build path

Click on configure build path

Click on Add externals jars button

Browse the selenium server jar file

Click on apply

Click on ok

When we click on ok button selenium server configure

Now we can start the selenium server

Configure the selenium server with eclipse by following above navigation

Goto run last tool drop down in eclipse(besides run button)

Clck on external tools configurations

Double click on the program

Click on browse file system

Browse the java location(C: program files/java/jdk/bin/java.exe)

Clck on another browse file system


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
52

Browse the jar folder location

Specify the arguemtns like below(-jar selenium-server-standalone-2.44.0.jar)

Click on apply

Click on ok

When we click on run selenium server and we can see server started
information in the console page of eclipse

Working with selenium RC:-

For working with selenium RC we need to create a object by importing default


selenium class from com.thoughtworks.selenium package.

Syntax:-

Default selenium obj=new default selenium

“server host”, server port, “Browser start command”, “Browser URL”)

DefaultSelenium s=new DefaultSelenium(“local host”, 4444, “*firefox


C://program files(X86) //mozila firefox.exe”,”http://);

s.start();

s.open(http://facebook.com);

s.windowMaximize();

Browser commands in selenium RC:-

Start()

To start the browser which we specify in the browser start command argument.

Syntax:- object.start();

Open()

To open the application in a opened browser

Syntax:- object.open(); object.open(“URL”);


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
53

windowMaximize();-

To maximize the application which we opened

Syntax:- object.windowMaximize();

Close():- To close the application

Syntax:- object.close();

Example

Prepare the test script to launch the facebook application in firefox browser,
maximize the application & close the application.

Package seleniumrc;

Import com.thoughtworks.selenium.DefaultSelenium;

Public class RCFirst{

Public static void main(string[] args){

DefaultSelenium s=new DefaultSelenium(“local host”, 4444,”*firefox


C://program files(X86)\\mozila firefox.exe)

s.start();

s.open(http://facebook.com);

s.windowMaximize();

s.close();

Business operation commands in selenium RC:-

Type():- To enter the value in a text box.

Syntax:- object.type(“element locator”, “value”);

Select();- To select the value in a list box.

Syntax:- object.select(“element locator”, “value”);

Check():- To check the check box/radio button

Syntax:- object. Check(“element locator”);


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
54

Uncheck():- To uncheck the check box.

Syntax:- object.uncheck(“element locator”);

Click():- To click on the element.

Syntax:- object.click(“element locator”);

Example:-

Prepare the test script to launch fb to enter email, password, select day, select
month, check the male radio button and click on create an account button.

DefaultSelenium s=new DefaultSelenium(“local host”,4444,”*firefox


C:\\program files(X86)\\mozila firefox.exe”,http://);

s.start();

s.open(http://facebook.com);

s.windowMaximize();

s.type(“id=email”,”kishore”);

s.type(“id=’ass”,”abcdefg”);

s.select(“id=day”,”24”);

s.select(“id=month”,”Apr;

s.check(“id=u-o-f”);

s.click(“id=u-o-i”);

Validations commands in RC:-

Iselementpresent:-

To verify whether the element is present in the application or not.

Syntax:- variable=object.iselementpresent(“element locator”)

Note:- All the commands return type is Boolean

Istextpresent:-

To verify whether the text is present in the application or not.


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
55

Syntax:- variable=object.istextpresent(“text”)

Example:-

Package seleniumrc;

Import com.thoughworks.selenium.DefaultSelenium;

Public class validations{

Public static void main(string[] args){

DefaultSelenium s=new DefaultSelenium(“localhost”,444,)

s.start();

s.open(http://facebook.com);

s.windowMaximize();

s.type(“id=email”,”abcdef”);

//verifying password available or not

Boolean a=s.iselementpresent(“id=pass”);

If(a==true)

System.out.println(“pass”+”password Available”);

Else

System.out.println(“fail”+”password not available”);

//verifying first name available or not

If(a.iselementpresent(“id=u-o-i”==true)

System.out.println(“pass”+”firstname available”);

Else

System.out.println(“fail”+”firstname not available”);

//entering password

s.type(“id=pass”,”XYZ123”);
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
56

if(s.Textpresent(“account”)==false)

system.out.println(“pass”+”account text not available”);

else

system.out.println(“fail”+”account text available”);

isEditable:- To verify whether the element is editable or not.

Syntax:- object.isEditable(“element locator”);

isChecked:- To verify whether the checkbox or radio button is checked or not.

Syntax:-variable=object.isChecked(“element locator”);

isAlertPresent:- To verify whether the alert message is present in the application


or not.

Syntax:- variable = object.isAlertPresent(No Arguemtns);

isSomethingSelected:- To verify whether any value has selected in the list box
or not.

Syntax:- variable=object.isSomethingSelected(“element locator”);

getTitle:- To capture the title of the application

syntax:- variable=object.getTitle();

getAllLinks:- To count the number of links in a application

syntax:- string[] variable=object.getAllLinks();

getAllButtons:-To count the number of buttons in a application.

Syntax: string[] variable=object.getAllButtons();

Step no Test Description Expected Result


1. Launch facebook application The title of the facebook application
in firefox browser should starts with f, should ends with
m, length of title should be 20, titile
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
57

should contains k
2. Enter email Password should be available, it
should be editable
3. Enter password First name should be available, should
not be editable, account text should be
available
4 Enter firstname Accounts text should nhot be
available. Day list box should be
available
5. Select day and month list Female radio button should not be
boxed checked and male radio button should
be checked
6. Launch yahoo mail Length of title of yahoo mail
application in the same application should be 10, it should be
browser less than facebook application title
length, 7th character should be k and
10th character should not be z.
7. Enter user name in yahoo Number of links in yahoo mail
mail application application should be greater than no
of buttons.

Package seleniumRC;

Import com.thoughtworkds.selenium.DefualtSelenium;

Public class Example{

Public static void main(string[] args){

DefaultSelenium s=new DefaultSelenium(“localhost”,4444,”*firefox


C:\\program files(X86)\\mozila firefox.exe”,http://);

s.start();

s.open(http://facebook.com_;

s.windowMaximize();

string a=s.getTitle();

if(a.startswith(“f”)==true)

system.out.println(“pass”);
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
58

else

system.out.println(“fail”);

if(a.endswith(“m”)==true)

system.out.println(“pass”);

else

system.put.println(“fail”);

if(a.length()==20)

system.out.println(“pass”);

else

system.out.println(“fail”);

if(a.contains(“k”)==true)

system.out.println(“pass”0;

else

system.out.println(“fail”);

s.type(“id=email”, “sharanya”);

if(s.iselementpresent(“id=pass”)==true)

system.out.println(“pass”+”password Available);

else

system.out.println(“fail”)

if(s.iseditable(“id=pass”)==true)

system.out.println(“pass”);

else

system.out.println(“fail”);

s.type(“id=pass”,”123456”);
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
59

if(s.iselementpresent(“id=u-o-1”)==true)

system.out.println(“pass”);

else

system.out.println(“pass”);

else

system.out.println(“fail”);

if(s.iseditable(“id=u-o-1”)==false)

system.out.println(“pass”);

else

system.out.println(“fail”);

if(s.istextpresent(“account”)==true)

system.out.println(“pass”);

else

system.out.println(“fail”);

s.type(“id=u-o-v”,”Aravelli”);

if(s.istextpresent(“account”)==false)

system.out.println(“pass”);

else

system.out.println(“fail”)

if(s.iselementpresent(“id=day”)==true)

system.out.println(“pass”);

else

system.out.println(“fail”);

s.select(“id=day”,”25”);
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
60

s.select(“id=month”, “Apr”);

if(s.ischecked(“id=u-o-i”)==false)

system.out.println(“pass”);

else

system.out.println(“fail”);

if(s.checked(“id=u-o-f”)==true)

system.out.println(“pass”);

else

system.out.println(“fail”);

s.open(http://yahoo mail.com)

b=s.gettitle();

if(b.length()==10)

system.out.println(“pass”);

else

system.out.println(“fail”);

if(b.length()<a.length())

system.out.println(“pass”);

else

system.out.println(“fail”);

if(b.charAt(6)==true)

system.out.println(“pass”);

else

system.out.println(“fail”);

if(b.charAt(9)==false)
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
61

system.out.println(“pass”);

else

system.out.println(“fail”);

s.type(“id=email”,”XYZ”);

string[] c=s.getAllLinks();

string[] d=s.getAllButtons();

if(c.length()>d.length())

system.out.println(“pass”);

else

system.out.println(“fail”);

JAVA OOP CONCEPTS


Java is the object oriented programming language. It supports the below
concepts.

1. Class
2. Object
3. Package
4. Inheritance
5. Polymorphism
6. Encapsulation
7. Abstraction

Inheritance:- it defines inheriting the members of /behaviour of one class to


another class.

Single Inheritance:-

In this we are inheriting the behaviour from one class to another class.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
62

Example:- package packone;

Class Abcdef{

Public void a1(){

System.out.println(“This is subclass”);

Public class Inher extends Abcdef{

Public void b1(){

system.out.println(“This is superclass”);

Public static void main{

Inher i=new Inher();

i.b1();

i.a1();

Multi level Inheritance:- in this we are inheriting the behaviour from one class
to another class from that class to another class.

Example:- package packone;

Class Abcdef{

Public void a1(){

s.o.p(“This is sub class”);

Class klmn extends Abcdef{

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
63

Public void b1(){

s.o.p(“This is klmn”);

Public class Inher extends klmn{

Public void c1(){

s.o.p(“this is super class”);

Public static void main(string[] args){

Inher i=new Inher();

i.c1();

i.b1();

i.a1();

Hierarchial Inheritance:-

In this we can inherit the behaviour from one class to multiple class.

Example:- package packone;

Class Abcdef{

Public void a1(){

s.o.p(“This is sub class”);

Class Klmn extends Abcdef{


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
64

Public void c1(){

s.o.p(“This is KLMN”);

Public class Inher extends Abcdef{

Public void b1(){

s.o.p(“This is super class”);

Public static void main{

Inher i=new Inher();

i.a1();

i.b1();

Klmn k=new Klmn();

.c1();

i.a1();

Hybrid Inheritance:-

In this we can inherit the behaviour from one class to another class into another
class etc.

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
65

Polymorphism:- Polymeans many and morphism means forms. Polymorphism


supports method overloading and method overriding.

Method Overloading:- one class contains same method name with different
arguments is called method overloading. Compiler will identify the methods
based on the arguments.

Package packone;

Public class methodovl{

//method overloading

Static void a1(int a, int b){

system.out.println(“a*b);

Static void a1(int k, int l, int m)

system.out.println(“k+l+m);

Public static void main(string [] args){

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
66

a1(20,20);

a1(40,30,100);

}
o/p: 400,170

Method overriding:- In this we are creating the same method name in


inheritance and sub class method will be overriding super class method.

Example:-

Package packone;

Class Abcd{

Void a1(){

system.out.println(“This is first”);

Public class mehtodovr extends Abcd{

Void a1(){

system.out.println(“This is second”);

Public static void main(){

Methodover m=new methodover();

m.a1();

o/p:- This is second

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
67

SELENIUM WEBDRIVER(2.53)
Web driver is the advanced for selenium RC which we can use to design the test
scripts and execute the test scripts in different browsers and in the different
environments.

Advantages of Web driver:-

 Like as RC we need not to start the server for web driver.


 We can access RC commands into web driver but we cannot access web
driver commands into RC.
 Default synchronization is applicable for page loadings in webdriver.
 We can handle multiple similar elements (links, buttons, images etc) in
selenium webdriver.
 We can handle alert messages pop up windows using web driver.
 We can handle mouse over operations (mouse movements) keyboard
operations in web driver.
 We can handle file uploads and downloads by integrating third party tool
called Auto it.
 We can handle web tables using web driver
 We can handle multiple windows (more than one window using web
driver)

Configuration of Webdriver with eclipse:-

For working with selenium web driver we need to configure selenium


standalone server with eclipse.

Navigation

Same navigation as RC upto configure jar files of eclipse

Working with webdriver:-

For working with webdriver we need to create an object by importing browser


driver class and we need to implement into web driver browser driver and web
driver we are importing from org.openqa.seleniumpackage

Syntax:-

FirefoxDriver f=new FirefoxDriver();


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
68

webDriver driver=f;

or

webdriver driver=new FirefoxDriver();

example:-

package WD;

import org.openqa.selenium.webDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class WDFirstClass{

public static void main(string[] args){

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

driver.quit();

Working with different browsers:-

By default webdriver supports firefox browser. If you want to work with other
browsers, we need to download the browser driver server.exe files and set up
the system properties.

To see the list of locators of elements in a chrome browser we are using firebug
lite and to see the list of locators in a IE we are using debugbar.

Working with internet explorer:-

For working with IE browser we need to download IE server.file exe file

Open the official website of selenium

Goto download tab


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
69

Click on internet explorer driver server

Extract the file into jars folder

Prepare the script like below

System.setproperty(“webdriver.ie.driver”,”C://users//vamshi//desktop//setwebD
river//jars//IEDriverserver.exe”);

Webdriver driver=new InternetExplorerDriver();

Driver.get(http://yahoomail.com);

Driver.Manage().window().maximize();

Working with Chrome:-

System.setpropoerty(“webdriver.chrome.driver”,”path of exe file”)

WebDriver driver=new ChromeDriver();

Driver.get(http://yahoomail.com);

Driver.mange().window().maximize();

FirebugLite:- This is the add-in for chrome browser which we can use to see the
list of locators of the elements in a chrome browser

Debugbar:- This is the add-in for internet explorer which we can use to see the
list of locators of the elements in a internet explorer browser.

Note:-

In every browser the locators of the elements will be same. But the way we are
seeing the locators will be different from one browser to another browser.

How webdriver will identify the elements webdriver will identify the elements
in application based on the locators by using find element method.

Syntax:- Driver.findelement(by.locator(“value”))

Business operation commands in webdriver:-

SendKeys:- To enter the value in a text box and to select the value in a list box.

Example:-
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
70

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

driver.findElement(By.id(“email”)).sendKeys(“kishore”);

driver.findElement(By.id(“pass”)).sendKeys(“abcdef”);

click:- To click on the element in a application.

Syntax:- Driver.findElement(By.locator(“value”)).click

Clear:- To Remove the value in a tect box.

Syntax:- Driver.findelement(by.locator(“value”)).clear();

Prepare the test script to launch the fb application in firefox browser, enter the
email, select the day as 24, select male radio button, clear the email value and
close the facebook application.

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

driver.findElement(By.id(“email”)).sendKeys(“sharanya”);

driver.findElement(By.id(“day”)).sendKeys(“24”);

driver.findElement(By.id(“u-o-f”)).click();

driver.findElement(By.id(“email”)).clear();

driver.quit();

Accessing RC commands into webdriver:-

We are using this option to access RC commands into webdriver. For accessing
RC commands we need to import a class called weDriverBacked selenium. By
creating an object so that with help o f the object we can access RC commands.

Syntax:-

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
71

webDriverBackedSelenium rc=new
WebDriverBackedSelenium(webDriverdrives “base URL”);

WebDriver driver =new FirefoxDriver();

Driver.get(http://facebook.com);

Driver.manage().window().maximize();

Driver.findElement(By.id(“meial”)).sendKeys(“abcdef”);

webDriverBackedSelenium rc=new webDriverBackedSelenium(driver,http://);

rc.type(“id=”pass”,”Abcdef”);

rc.check(“jik”);

driver.findElement(By.id(“ds”)).click();

driver.findElement(By.id(“pass”)).sendKeys(“sheres”);

Validation commands in webdriver:-

isDisplayed():-

To verify whether the element is displaying in the application or not.

Syntax:- driver.findElement(By.id(“locatorvalue”)).isDispalyed();

Example:-

Public static void main

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

driver.findElement(By.id(“email”)).sendKeys(“kishore”)

Boolean a –driver.findElement(By.id(“pass”)).isDisplayed();

If(a==true)

Sopln(“pass”);

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
72

Else

Sopln(“fail”);

isEnabled():-

To verify whether the element is enabled or not.

Syntax:- driver.findElement(By.locator(“value”)).isEnabled();

isSelected():- To verify whether the check box/radio button selected or not.

Syntax:- driver.findElement(By.locator(“value”)).isSelected();

getTitle():- To capture the title of the application.

Syntax:- driver.getTitle();

getCurrentUrl():- To capture the current URL of the application.

Syntax:- driver.getCurrentUrl();

getPageSource():- To capture the source code of the page.

Syntax:-driver.getPageSorce();

getAttribute():- To capture the locator value of the element from the application.

Syntax:- driver.findElement(by.locator(“value”)).getAttribute);

getTagName():- To capture the tag name of the element.

Syntax:-driver.findElement(by.locator(“value”)).getTagName(“locahost”);

getLocation():- To caputer the location of the element from the application.

Syntax:-driver.findElelement(by.locator(“value”)).getLocation(“local host”);

getSize():- To capture the size of the element.

Get():- To open the application in a implemented browser

Syntax;-

Webdriver driver.get(“URL”)

getText():- To capture the name of the element.


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
73

Syntax:- driver.findElement(By.locator(“value”)).getText();

Example:- webDriver driver=new FirefoxDriver();

Driver.get(http://yahoomail.com);

Driver.manage().window().maxmize();

STRING App-url=driver.getCurrentUrl();

Sopln(App-url);

String a=drivr.findElement(By.id(“login-username”)).getAttribute(“class”);

System.out.println(a);

System.out.println(driver.findElement(By.id(“login-
username”)).getTagName());

Sopln(driver.findElement(By.id(“login-username”)).getSize());

Sopln(driver.findElemtn(By.id(“login-username”)).getRect());

Sopln(drivr.getTitle());

Sopln(driver.getPageSource());

webElement:-

sometimes we are working on the same element repeatedly for multiple times.
In that case instead of identifying the same element again and again for multiple
times, we are creating the ref object for that element using weelement. So that
here after we can start working on the element with the help of the object.

Syntax:- webElement object=driver.fidnElement(by.locator(“value”));

Example:- public static void main{

webDriver driver=new FirefoxDriver();

driver.get(http://yahoomail.com);

driver.manage().window().maximize();

webElement uid=driver.findElement(By.id(“login-username”))

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
74

uid.sendKeys(“Abcdef”);

uid.clear();

booloean a =uid.isDisplayed();

uid.getTagName();

Xpath:-

Xpath is nothing but the location of the element in a html tree structure /pge.
We are considering Xpath is the unique locator of the element in application.
Because in one location two elements will not appear. We can identify the
Xpath either manually/ by using the add-in called Firepath.

What is Firepath?

Firepath is the add-in for Firefox browser.

Which is installing on the top of the firbug

There are 2 different types of Xpaths available for the elements

1. Absolute Xpath(location of the element from the starting of html)


2. Relative Xpath/Attribute based Xpath/locator based(Anywhere in the
page based on the unique of the element locator)

Public static void main(string[] args){

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

driver.findElement(By.Xpath(“html path”)).senKeys(“abcdef”);

drivr.findElement(By.Xpath(“/”*[@id=’pass’]”)).sendKeys(“sss”);

webElement uid=driver.findElement(By.Xpath(“html”));

webElement pwd=driver.findElement(By.Xpath(“id=pg”));

uid.clear();

pwd.clear();
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
75

Reusable Methods:- We are using reusable methods to perform the validations


in selenium. Sometimes we need to write the same logic for multiple times. In
that case instead of writing the same lines of the code again and again, we are
making that logic as a method. So that here after, we are using to method
whenever we required that logc.

Example:-

Package webd;

Import org.openqa.selenium.By;

Import org.openqa.selenium.webDriver;

Import org.openqa.selenium.firefox.FirefoxDriver;

Public class ReusableMehtods{

Public static webDriver driver;

Public static void launchApp(Sring url){

Driver=new FirefoxDriver();

Driver.get(url);

Driver.manage().window().maximize();

Public static void closeApp(){

Driver.quit();

Public static void elementpresent(string loc,Boolean exp){

Boolean a=driver.findElement(By.id(loc)).isDisplayed();

If(a==exp)

System.out.println(“pass”);

Elese

System.out.println(“pass”);

Else

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
76

System.out.println(“fail”);

Public static void title_length(int exp){

String a=driver.getTitle();

If (a.length()==exp)

s.o.p(”pass”+”-“+a.length());

else

s.o.p(”fail”+”-“+a.length());

public static void main(string[] args){

ReusableMethods.launchApp(“http://yahoomail.com”);

ReusableMethods.title_Length(15);

ReusbleMethods.ElementPresent(“login-username”,true);

ReusableMethods.CloseApp();

ReusableMethods.launchApp(http://facebook.com);

ReusableMethods.title-length(30);

ReusableMethod.elementpresent(“email”,true);

ReusableMethods.elementpresent(“pass”,false);

ReusableMethods.elementpresent(“day”,true);

ReusableMethods.closeApp();

If we want to work with application no need of using find element.

If we want to work with element we use findelement.

Jxl.jar

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
77

FromExcel:- we are using this option to read the data from excel. For reading
the data from excel we need to configure JXL.jar/POI.jar with eclipse.

Example:-

Public static void main(string[] args) throws exception{

FileInputStream f=new FileInputStream(“C:path//test1.xls);

Workbook wb=workbook.getworkbook(f);

Sheet s =wb.getSheet(“abcd”);

Sopln(s.getCell(0,0).getContents());

Sopln(s.getCell(1,0).getContents());

Sopln(s.getCell(2,0).getContents());

Save with 97/2003 format.

Example:-

P s v m throws exception{

FileInputStream f=new FileInputStream(“C://users//test1.xls”);

Workbook wb=workbook.getWorkbook(f);

Sheet s=wb.getSheet(“abcd”);

WebDriver driver=new FirefoxDriver();

Driver.get(s.getCell(4,0).getContents());

Driver.manage().window().maximize();

Driver.findElement(By.id(s.getCell(0,0).getContents())).SendKeys(s.getCell(2,0
).getContents()));

Driver.findElement(By.id(s.getCell(1,0).getContents())).SendKeys(s.getCell(3,0
).getContents()));

Email Pass Sharu Sharu123 URl

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
78

SSM – social security number

Working with multiple rows in excel:-

FileInputStream f=new FileInputStream(“c://users//test.xls”);

Workbook wb=workbook.getworkbook(f);

Sheet s=wb.getSheet(“abcd”);

Int rc=s.getRows();

Int i;

For(i=0;i<rc;i++){

Sopln(s.getCell(0,i).getContents());

A B C D

o/p Abc
abc 123
123 Def
Def XYZ
XYZ

Working with multiple columns in excel:-

FileInputStream f=new FileInputStream(“path”);

Workbook wb=workbook.getworkbook(f);

Sheet s=wb.getSheet(“sheet1”);

Int cc=s.getColumns();

Int i;

For(i=0;i<cc;i++){
sopln(s.getCell(i,0).getContents());

O/P:- Abc 123 456 789


Abc
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
79

123
456
789

We are using this option to write the data into excel into test scripts.

Working with multiple rows and columns:-

FileInputStream f=new FileInputStream(“C://users//test1.xls”);

Workbook wb=workbook.getworkbook(f);

Sheet s=wb.getSheet(“abcd”);

Int cc=s.getColumns();

Int rc=s.getRows();

Inti;

Intj;

For(i=0;i<cc;i++){

For(j=0;j<rc;j++){

String val=s.getCell(i,j).getContents();

If(val.equals(“sharanya”==true)

Sopln(i+”-“+j);

Writing the data into excel:-

Public class excel write{

P s v m throws exception{

Int a=30; int b=40; int c=a*b; int d=b-a;

FileOutputStream fo=new FileOutputStream(“C://users//Results.xls”);

Writableworkbook wwb=workbook.createworkbook(fo);

Writablesheet ws=wwb.createSheet(“value”,1);

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
80

Writablesheet ws1=wwb.cretesheet(“value1”,2);

Label l=new label(0,0,”c value is “+c);

Label l1=new label(0,0,”D value is “+d);

Ws.addCell(l);

Ws1.addCell(l1);

Wwb.write(); - save the xl file

Wwb.close();

From notepad:-

We are using this option to execute the test scripts by passing the data from
notepad.

Example:-

Package webd;

Import java.io.BufferReader;

Import java.io.FileReader;

Public class Notepad{

P s v m throws Exception{

FileReader f=new FileReader(“C://user//sample.txt”));

BufferedReader b=new BufferedReader();

Sopln(b.readline());

String a=b.readline();

String[] c=a.split(“ “);

webDriver driver=new FirefoxDriver();

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
81

driver.get(c[0]);

driver.manage().window().maximize();

driver.findElement(By.id(“email”)).SendKeys(c[1]);

driver.findElement(By.id(“pass”)).SendKeys(c[2]);

Reading the data in multiple rows in notepad:-

Public class NP-multipleRows{

P s v m throws exception{

FileReader f=new FleReader(“C://users//sample.txt”);

BufferedReader b=new BufferedReader(f);

String s;

While ((s=b.readline())!null){

Sopln(s);

Sharanya

1234

5678

9101112

From Console:-

We are suing this option to execute the test scripts by passing the data from
console during execution. For reading the data from console we are creating the
object for scanner class.

Syntax:-
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
82

Scanner object=new scanner(system.in);

Example:-

Package webd;

Import java.util.scanner;

Public class console{

Psvm{

Scanner s=new scanner(system.in);

Sopln(“enter A”);

Int a=s.nextInt();

Sopln(“enter B”);

Int b=s.nextInt();

Sopln(a*b);

o/p:- enter A 10

enter B 20

200

From Application:

Scanner s=new scanner(system.in);

webDriver driver=new FirefoxDriver();

sopln(“enter URL”);

driver.get(s.next());

driver.manage().window().maximize();

sopln(“enter email loc”);


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
83

string email=s.next();

sopln(“enter email value”);

string email-val=s.next();

sopln(“enter password loc”);

string pwd=s.next();

sopln(“enter password value”);

string pwd-val=s.next();

driver.findElement(By.id(email)).sendKeys(email-val);

driver.findElement(By.id(pwd)).SendKeys(pwd-val);

output:-

enter URL http://facebook.com

enter email locator email

enter email value sharanya

enter password lcator pass

enter password value sharanya123

From Database:- we are using this option to read the data from database. For
working with database we need to configure OJDBC.jar file (oracle java
database connection) with eclipse.

Handling mouse ovr operations topic here

Prepare the topic to open the login page of Rediffmail application, click on go
button (now alert msg will display) capture the text of alert msg and close the
alert message.

Handling Alert Messages in WebDriver:-

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
84

We are using this option to handle the alert messages in application. Sometimes
during execution some alert messages interrupt the application. Tool cannot
able to continue the execution. In that case we need to switch/capture to that
alert message and handle the alert message. We can eliminate them by
implementing alert interface.

Example:-

P s v m throws exception{

Webdriver driver=new firefoxDriver();

Driver.get(https://mail.refiff.com/lgi-bin/login-lgi);

Driver.manage().window().maximize();

//clicking on go button

Driver.findElement(By.Xpath(“path”)).click();

//switch to alert

Alert a =driver.switchTo().alert();

//capturing text from alert message

Sopln(a.getText());

Thread.Sleep(5000);

//closing alert

a.dismiss();

Working with web tables:- We are using this option to work with web tables in
application.

Result

Sno From To case

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
85

Prepare the test script to read the data from 2nd row 4th column cell from the
gainer table of nseindia.com application.

webDriver driver=new FirefoxDriver();

driver.get(“https://www.nseindia.com----“);

driver.manage().window().maximize();

sopln(driver.findElement(By.Xpath(“html/body----,getText());

prepare the test script to count the number of rows in a webtable.

webDriver driver=new FirefoxDriver();

driver.get(https://www.nseindia.com);

driver.manage().window().maximize();

//creating web table for table

webElement table=driver.findElement(By.Xpath(“html/body----“):

list<webelement>rc=table.findelements(By.tagName(“tr”);

int i;

for(i=2;i<=rc.size();i++){

sopln(driver.findElement(By.Xpath(“html/body/---tr[+”i+”]td[]”,getText());

print all the column names of the webtable.

Print the script names from the gainers table which are having greater than 2%

Webdriver d=new FirefoxDriver();

d.get(https://nseindia.com.....);

d.manage().window().maximize();

webElement table=d.findElement(By.Xpath(“table path”);

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
86

list<webElement>rc.table.findElements(By.tagName(“tr”));

int i;

for(i=2;i<rc.size();i++){

string a=d.findElement(By.Xpath(“3rd column path/tr[“+i+”]/td[3]”).getText();

double val=double.parseDouble(a);

if(val>=2.0)

sopln(d.findElement(By.xpath(“1st column path/tr[“+i+”]/td[1]).getText());

string
val=driver.findelement(By.Xpath(“html/tbody/tr[“+i+”]/td[3]”)).getText();

sikuli & Autoit - tools

scriptEditor, Autoit windowinfo - (mega file upload) (we transfer)

Handling windows with AutoIT:-

(Handling file uploads & downloads)

We are using this option to handle the file uploads and downloads in selenium.
For handling file uploads, we are using AutoIT and executes the AutoIT
through webdriver.

What is AutoIT:-

AutoIT is the tool, which we can use to automate the windows applications, for
working with AutoIT, we need to download the tool, run to script in AutoIT and
also execute the script through webdriver.

AutoIT program:-

winActivate(“File Upload”)

controlFocus(“File Upload”,” “, “edit”)

controlSetText(“FileUpload”,” “, “edit1”, “path.doc”)

sleep(5000)

controlclick(“fileUpload”,” “, “Button1”)
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
87

By using webDriver:- Once we prepare the AutoIT program like above we need
to save the file and compile the file. When we compile the AutoIT file, one
“exe” file will generate. Once exe file has generated we can execute the file
through webdriver.

Example:-

webDriver driver=new FirefoxDriver;

driver.get(http://www.megafileupload.com/);

driver.mange().window().maximize();

driver.findElement(By.Xpath(“path”).Click());

driver.findElement(By.Xpath(“path”).Click());

Runtime.getRuntime().exec(“//path//filename.exe”);

Woring with multiple windows:-

We are using this option to handle multiple windows using webdriver. Before
working with multiple windows we need to count (through) those windows by
using get window handles.

Example:-

Prepare the test script to open the facebook application click on data policy link,
print the no. Of links in every window and close every window.

Program:-

Webdriver driver=new FirefoxDriver();

Driver.get(http://facebook.com);

Driver.manage().window().maximize();

//clicking on data policy link

Driver.findElement(By.Xpath(“datapolicypath”)).click();

ArrayList a =new ArrayList(driver.getWindowHandles());

Int i;
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
88

For(i=0;i<a.Size();i++){

Sopln(driver.SwitchTo().window((string)a.get(i)).findElements(By.tagName(“a
)).Size());

Driver.SwitchTo().Window((string)a.get(i)).close();

Example:-

Prepare the test script to count the no. Of windows, enter something in the first
window, enter something in the second window.

Program:-

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

//clicking on data policy links

Driver.findelement(By.Xpath(“path for data policy”)).click();

Arraylist a =new Arraylist(driver.getWindowHandles());

webDriver
first=driver.SwitchTo().window((string)a.get(0));first.findElement(By.id(“day”)
).SendKeys(“24”);

first.findElement(By.id(“month”)).SendKeys(“Apr;

WebDriver second=driver.SwitchTo().Window((string)a.get(1));

Second.findElement(By.id(“email”)).SendKeys(“sharanya”);

Working with web Tables:- We are using this option to work with web Tables
in selenium

Handling keyboard operations:- For handling keyboard operations we are using


actions class

Actions o=new Actions(driver);

a.SendKeys(Keys.CONTROL+”t”).build().perform();
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
89

a.SendKeys(Keys.F5).build().perform();

a.SendKeys(Keys.F3).build().perform();

a.doubleclick(on element);

a.draganddrop(source,target);

drag drop

drag and drop:-

Actions a=new Actions(driver);

webElement img=driver.findElement(By.Xpath(“html/”));

WebElement uid=driver.findElement(By.Xpath(“html/”));

a.dragAndDrop(img,uid).build().perform();

Synchronization point:-

The time gap between tool and application is called synchronization point.
During the execution if the application is taking more time to display the
elements, tool cannot able to continue the execution. In that case we are giving
instructions to tool to wait for some more extra time until the elements are
available. This instructions we are providing to the tool in two different ways.

1. Explicit wait
2. Implicit wait

Explicit wait:- We are using explicit wait to stop the execution temporarily
irrespective of the application. We are using thread. Sleep for explicit wait in
selenium.

Syntax:-

Thread.Sleep(time in milliseconds);

Example:-

Public class multiplewindows{

P s v m throws exception{

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
90

webDriver driver=new FirefoxDriver();

driver.get(http://facebook.com);

driver.manage().window().maximize();

driver.findelement(By.id(“email”)).SendKeys(“sheru”);

thread.sleep(60,000);

driver.findelement(By.id(“pass”)).SendKeys(“1234”);

Implicit wait:-

We are using implicit wait to stop the execution temporarily based on the
availability of the element in a application.

Syntax:-

Driver.manage().timeouts().implicitlywait(60,Timeunit.SECONDS);

Example:- public class MultipleWindows{

P s v m throws exception{

Webdriver driver=new FirefoxDriver();

Driver.manage().timeouts().implicitlywait(60,Timeunit,SECONDS);

Driver.get(http://facebook.com);

Driver.manage().window().maximize();

Driver.findelement(By.id(“email”)).SendKeys(“sharaya”);

Driver.findelement(By.id(“pass”)).SendKeys(“1234”);

Webdriver wait:-

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
91

We are using webdriver wait to stop the execution temporarily based on the
behaviour/availability of the element in application.

Example:-

Public class multiplewindows{

P s v m throws exceptions{

Webdriver driver=new FirefoxDriver();

Driver.get(http://facebook.com);

Driver.manage().window().maximize();

Driver.findelement(by.id(“email”)).SendKeys(“abcdef”);

WebDriverWait w=new WebDriverWait(driver,20);

w.untill(ExpectedConditions.numberofElementsToBe(By.tagName(“a”),50));

driver.findelement(By.id(“pass”)).SendKeys(“1234”);

list<webelement>a=driver.findElements(By.tagName(“a”));

sopln(a.size());

Handling mouseover operations in webDriver:-

We are using this option to handle the mouse moments and keyboard operations
in webDriver.

For handling mouse operations we are importing actions by creating an object.


So that with the help of that object we can handle mouse operations.

Prepare the test script to launch the nseindia.com application, move the cursor
to corporate menu and click on benefits of listing under the menu

P s v m throws exception {

webDriver driver=new FirefoxDriver();

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
92

driver.manage().timeout().implicitlywait(60,Timeunit.SECONDS);

driver.get(“http://www.nseindia.com”);

driver.manage().window().maximize();

//creating element for corporate

webElement corpoorates=driver.findElement(By.Xpath(“ “));

//creating Actions object

Actions a =new Actions(driver);

//moving the cursor to corporate

a.moveToElement(corporate).build().perform();

Thread.Sleep(5000);

Driver.findElement(By.Xpath(“ “)).Click();

[re[are the test script to move the cursor to corporate and print all the links

FRAMEWORKS
Framework is the folder structure which contains folders, subfolders and files
can be accessed by across the project. There are 2 different types of frameworks
available in selenium.

1. Built in framework
2. User defined framework

Built in framework:-

Built in framework is the framework which has created by vendor and we are
using this to automate the project. Thee are two different Buillt in frameworks.
We are implementing in selenium.

1. JUnit(java unit)
2. TestNg(Testnextgeneration)

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
93

JUnit:- Junit is the unit testing framework which is using by the java developers
to perform unit testing. For working with JUnit framework we need to configure
junit.jar file with eclipse. (jnit.jar download)

Working with Junit:-

Once we download the jnit.jar file and configure with eclipse we can start
working on Junit framework. For working with Junit framework we are using
Annotations.

What is Annotation?

Annotations are nothing but predefined classes which contains reusable line of
the code.

Every annotation starts with the symbol called’@’.

List of Annotations:-

@Before it executes before executes every test

@After It executes After executes every test

@BeforeClass it executes before executes all the tests

@AfterClass it executes After executes all the tests

@test This is the test which contains the code

@Ignore To not to executes any specific test

Example:- (dependent clas)

Public class JunitClass{

@Beforeclass

Public static void a1(){

Sopln(“This is Before”);

@Afterclass

Public static void b1(){


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
94

Sopln(“This is after”);

@test

Public void c1(){

Sopln(“This is test1);

@test

Public void d1(){

Sopln(“This is test2”);

@test

@Ignore

Public void e1(){

Sopln(“This is test3);

Output:-

This is before

This is test1

This is test2

This is after

Example 2:- (independent class)

public class Junitclass{

@Before
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
95

Public void a1(){

Sopln(“This is Before”);}

@After

Public void b1(){

Sopln(“This is After”);}

@Test

Ublic void c1(){

Sopln(“This is Test1”);

@Test

Public void d1(){

Sopln(“This is Test2”);}

@Test

Public void e1(){

Sopln(“This is Test3”);

o/p:-

This is Before

This is Test1

This is After

This is Before

This is Test2
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
96

This is After

This is Before

This is Test3

This is After

Example:-

Package junit;

Import java.util.list;

Import java.util.concurrent.Timeunit;

Import org.junit.After;

Import org.junit.Before;

Import org.junit.test;

Import org.openqa.selenium.By;

Import org.openqa.selenium.webdriver;

Import org.openqa.selenium.webelement;

Import org.openqa.selenium.firefox.FirefoxDriver;

Import junit.framework.Assert;

Public class Example{

Public static webDriver driver;

@Before

Public void launchApp(){

Driver=new firefoxDriver();

Driver.manage().timeouts().implicitlywait(60,Timeunit.SECONDS);

Driver.get(“http://nseindia.com”);
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
97

Driver.manage().window().maximize();

@After

Public void CloseApp(){

Driver.Close();

@Test

Public void test2(){

String url=driver.getCurrentUrl();

Assert.assertequals(true,url.contains(“.com”));}

@Test

Public void test1(){

List<webelement>links_count=driver.findelements(By.tagName(“a”));

Assert.assertEquals(20,links_count.Size());}

(Testing with eclipse)

TestNG:- TestNG is the advanced for Junit which we can us to perform unit
testing and automate the project.

Advantages:-

1. Comparatively with Junit we have more annotations in testng.


2. Comparatively with Junit we have more assertions in testng.
3. We can prioritize the test script execution in testng.
4. We can get the testing results in various formats like html, xml, emailable
etc.
5. We can execute multiple testing test at a time as a suit through xml files
6. Supports parameterization

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
98

Installation of testNG with eclipse:-

We need to configure test ng with eclipse

Open the browser enter the below URL

http://tesng.org/doc/download.html

click on enter

eclipse plug-in

copy the update site for release link under eclipse plug-in

go to eclipse

help

click on install new software

click on add button

specify the name as test ng

paste the URL in the value

click on ok

select the test NG checkbox

click on next

click on next

select terms

click on finish

restart

goto the help menu in eclipse

click on eclipse market place

specify test NG in find


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
99

click on go button

click on install

click on next

click on finish

restart now

We can also install the test NG with eclipse from eclipse place under help menu
in eclipse

List of Annotations in test NG

@before suite

@After suite

]@Before Test

@After Test

@Before class

@After Class

@Before method

@After method

@test ignore

Example:-

Public class Sample{

@Test (priority=2)

Public void f(){

Sopln(“This is test1”);}

@Test(priority=3)

Public void f1(){

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
100

Sopln(“This is test2”);}

@Test(priority=1)

Public void f2(){

Sopln(“This is test3”);

@Before method

Public void Beforemethod(){

Sopln(“This is Beforemethod”);}

@After method

Public void Aftermethod(){

Sopln(“This is after method”);}

@Before class

Public void Beforeclass(){

Sopln(“This is before class”):}

@After class

Public void Afterclass(){

Sopln(“This is Afterclass”);}

@Before Test

Public void BeforeTest(){

Sopln(“This is Before Test”);}

@AfterTest

Public void AfterTest(){

Sopln(“This is AfterTest”);}

@BeforeSuite
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
101

Public void BeforeSuite(){

Sopln(“This is BeforeSuite”);}

@After Suite

Public void aftersuite(){

Sopln(“This is after suite”);}

Output:-

Before suite Test1


Before Test After method
Before class Before method
Before method Test2
Test3 After method
After method After class
Before method After Test

After compilation of design the test script like above. We need to run the script
as test NG test. Once we run the script test NG will execute and we can see the
result in test o/p folder in package project.

Designing test NG script n real time:-

Usually in project we are designing one manual test NG test in one class

Example:- (counting list boxes)

Package test ng;

Import org.testng.annotations.test;

Public class class2{

Public static webdriver driver;

@Test

]public void f(){

Driver.findelement(By.name(“new user”)).click();

List<webelement>list_count=driver.findelements(By.tagname(“select”));
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
102

Assert.assetEquals(lst_count.Size(),2);}

@Beforemethod

Public void before method(){

Driver=new firefoxDriver();

Driver.manage().timeouts().implicitlywait(60,Timeunit,SECONDS);

Driver.get(http://qshore.com/unum/login.php);

Driver.manage().window().maximize();}

@After method

Public void Aftermethod(){

Driver.close();}

Example:-

Public class class1{

PUBLIC STATIC WEBDRIVER DRIVER;

@Test

Public void f(){

Driver.findElement(By.name(“txt”)).SendKeys(“sharanya”);

Org.testng.Assertequals(driver.findelement(By.name(“pwd”)).isenabled()true);

Driver.findelement(By.name(“pwd”)).SendKeys(“1234”);

Driver.findelement(By.name(“sub”)).click();

String url=driver.getcurrenturl();

Org.testng.Assert.assetequals(url.contains(“cases”),ture);

(Repeat it down)

After successfully complete of designing individual test ng test, we need to call


all the individual scripts into xml file and executes multiple scripts as a suite
through xml file at a time.
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
103

How to create xml file and how to generate xml file

Navigations to create xml file:-

Right click on the package

New

Click on file(xml)

Specify the xml file name with .xml

Click on ok

Click on source view in xml file

Prepare the xml program like below

Example:-

Before <suite name= “Regression suite”>

<test name= “Regression Test”>

<classes>

<class name=”testngg.class2”/>

<class name=”testngg.class1”/>

</classes>

</test>

After </suite>

Defect Reporting:- After completion of execution , if we identify any


mismatches and we are reporting as defect to development team.

Once we prepare the xml script like above, we need to run the script by right
clicking on the file and click on “test ng suite”

When we run as “test ng suite’, all the test ng test in xml file will execute and
generate the result.

User Defined Frameworks:-


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
104

User defined frameworks is the framework which is creating by user and


implementing to design the test cripts.

In selenium, we can create four different types of user defined frameworks.

Linear framework

Modulor or Keyword driver framework

Datadriven framework

Hybrid framework

There is no official terminology called framework in selenium but how


effectively we utilizing a selenium components to design the test script, based
on that we have above four different types of frameworks

Linear framework:- This is the first generation of selenium framework. In this


framework we are designing “one testscript in one class” by hard coding the
data directly in test scripts and executes individual scripts.

Data driven framework:- In this framework we design one test script in one
class by passing dta from excel and export the output in excel and executes
individual test script.

Modular framework:- In this framework we are designing one test script in one
method by passing the data from excel and export the output into excel. After
successfully completion of design the individual scripts into individual methods,
we are calling the required scripts into driver scripts with method name.

Hybrid framework:- This is the combination of keyword and data driven


framework. In selenium, in this framework we designing one test script in one
method by passing the data form excel, export the output into excel and perform
validation using reusable methods.

After completion of design the individual scripts in individual methods we are


calling the required scripts into driver scripts and execute multiple scripts at a
time.

Note:- In every project automation testing process starts with designing the
framework folder structure. It will be designing by automaton, test load or

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
105

automation tester in a sharefolder of the project. Then only it will be accessing


by across the team.

->Iteration is the part of cycle

=>1 Test case is repeated for 2/3 time i.e iteration

Different folders in hybrid framework:-

Package com.Qshore;

Import java.io.fileInputStream;

Public class Reusable methods{

Creating non-static variables & objects

Public web Driver driver;

Public filInput Streamf;

Public workbook wb;

Public Sheet s;

1. Eclipse:- which is using to manage the eclipse


2. Jars:- Which is using to manage required jar files
3. Scripts:- which we are using to manage the test scripts which we designed
in project.
4. Test Cases:- Which is we are using to manage the manual test cases to
automate
5. Test Data:- To manage the excel files which are used to pass the data into
test scripts
6. Test Results:- Which we are using to manage the excel files to upload the
results.

Note:-

Folders which are available in framework are customized folders. That measns
according to the project requirement we can customize the no of folders, the no
of folders and also edit the names of the folders. Creating hydbrid framework is
the one time activity. Once we design senior tester in a project will be involving
to design/create the files in framework folder strcture.
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
106

Test script Design:-

Once the framework structure is available with all the required files, we need to
start designing the test script with framework structure.

While designing we are writing one test script in one method in a class.

Example:-

Public class Reusablemethods{

//***************

//TestName: launchApp

//Des: To launch the App

//Author : Sharayna

//Date created : 08182016

//***************

Public void launchApp(string URL){

//****

Public void closeApp(){ }

//******

Public void elementpresent(){ }

//******

Public void elementEnabled() { }

Etc

Example:-

Public class modeule1{

Reusablemethods r=new Reusablemethods();

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
107

r.launchApp();

r.CloseApp();

r.elementpresent();

Driver Script:- driver script is the script which we are using to execute multiple
scripts. After successfully completion of designing the individual scripts in
individual methods like above, we need to call all the required scripts into driver
script and execute multiple scripts at a time.

Example:- public class DriverScript{

P s v m() throws Exception {

Module1 m=new Modeule11();

m.registration();

Defect Reporting:- After successfully completion of driver script execution tool


will display the results, we need to analyze the results and report the defects to
the development team if there is any mismatch between expected and actual
results.

Selenium Grid:- We are using selenium grid to execute the test script parallely
in different browsers and in different environments. For working with selenium
grid we need to configure the Hub and register notes with hub.

What is Hub:- Hub is the Central system where we can write the scripts.

What is Node:- Node is the individual machine which has register under hub.

Navigation to configure hub:-

Download the selenium standalone serverjar (2.53)file

Open the command prompt

Navigate the command prompt to selenium server jar file location

“java –jar <name>.jar-role hub”


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
108

Click on enter

When we click on enter grid hub will be starting and we can see the hub
configuration information in the below location “local host: 4444/grid/console”

Note:- Once we start the grid hub we should not close that command prompt.
(don’t close cmd prompt when we work with node)

Registering nodes with the hub:- Once we start the hub we need to register
individual nodes with the hub.

Navigation:-

Open the new command prompt

Navigate the command prompt to selenium server location

Enter the below command java – jar < selenium server.jar role node – hub
http://localhost:4444/grid/register

Click on enter

When we click on enter node will be registering with the hub and we can see the
node information in the below location.

Localhost: 4444/grid/console.

Once we register the nodes with the hub we need to design the script in eclipse
for executing through grid for working webdriver in grid we are using desired
capabilities and remote webdriver.

Public class sample {

P s v m{

Creating Reusable methods:- (continuous of test Results)

After successfully completion of design frameworks senior members in project


will be involving to create the reusable methods to perform the validations in
scripts.

Usually while starting they are creating few methods in a class and the same
class will be updating in future with multiple methods by the team members

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
109

Script design ( After successfully completion of designing reusable methods,


team members will start design the test scripts. Usually we are designing one
test script in one individual method in a class. By passing the data from the
excel and also perform the validations using reusable methods.

//counting no of links

r.elementscount(“a”,20);

//counting no of test boxes

r.elementscount(“select”,2);

//creating webelement for industry list box

Webelement industry=r.driver.findelement(By.Xpath(“-
“)(r.s.getCell(0,5).getContents()));

//counting no of values in list box

List<weelement>values_count=industry.findelements(By.tagname(“option”));

If(values_count.Size()==5)

Sopln(“pass”)

Else

Sopln(“fail”);

r.closeapp();

Reusable Method:-

Public void elementsCount(string loc,int exp){

Count=driver.findelements(By.tagName(loc));

If(count.size()==exp)

Sopln(“pass”)

Else

Sopln(“fail”)

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
110

(continue to driver script concept)

Package driver;

Public class Qshore_DriverScript{

P s v m throws exception

Employer e=new employer();

e.er_login();

Apache Maven:- Maven is the build configuration and version controlling tool
which has developed by Apache. We are using maven to implement frameworks
to automate the projects.

For working with maven, we need to install that with eclipse

Navigation:-

Open eclipse

Goto the help menu

Click on eclipse market place

Enter maven and click on go

Click on install in maven

Next

Next

Finish

Creating maven project:-

Once we install the maven with eclipse we need to create maven project in
eclipse.

Navigation

Install the maven with elcipse like above

Go to the file menu in eclipse


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
111

New

Other

Maven

Double click on maven project

Next

Next

Specify the grouId(packagename)

Specify the actifactID(projectName)

Click on finish

When we click on finish button maven project will be creating in eclipse.

Once we create the maven project we need to add dependencies (required jar
files we can add) with pom.xml(project object model). This pom.xml file we are
using to configure the required jar files (dependiencies).

Mavencentral repository

Pom.xml syntax

</dependency>

<groupId>jexcelapi</groupId>

<artifactId>jxl</artifactId>

<version>2.6</version>

</dependency>

Once we add the required dependencies, we can start designing the test scripts
under src/test/java in maven project.

Selenium Grid:-

Designing test scripts in eclipse

Grid with webdriver


QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
112

Psvm{

DesiredCapabilities d=new DesiredCapabilities();

d.firefox();

RemoteWebDriver driver=new RemoteWebDriver(d);

Driver.get(http://facebook.com);

Driver.manage().window().maximize();

Grid with RC

Psvm{

Selenium s=new DefaultSelenium(host, port, command, URL);

s.start;

Log4Jwe are not using this log4j)

Log4J is using by the java developers in the frameworks during unit testing to
generate the log files. For working with log4j we need to download the jar file
and configure with eclipse.

(log4j.jar)1.2.47 we need to download zip (2nd second)

After that we need to add the file in src.

Log4j.properties file:-

We are using this file to configure log4j settings with eclipse. This
log4j.properties file we need to create under src in a package explored.

File=> log4j.properties:-

#Application logs

Log4j.logger.devpinoglogger=DEBUG,dest1

Log4j.appender.dest1=org.apache.log4j.RollingFile

Log4j.appender.dest1.maxFileSize=5000KB

Log4j.appender.dest1.MaxBackupIndex=3
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
113

Log4j.appender.dest1layout=org.apache.log4j.pattern

Log4j.appender.dest1.layout.conversion pattern=%d{MM/DD/YYYY
HH:MM:SS} %c %m %n

Log4j.appender.dest1.File=C:\\users\\Vamshi\\desktiop\\framework\\Results\\12
3.log

//do not append the old file. Create a new log file every time.

Log47.appender.dest1.Append=false

Create-> class=> log.java

Package sharanya;

Import com.gargoylesoftware.htmlunit.webconsole.logger.

Public class log{

P s v m{

Logger APPLICATION_LOGS=logger.getLogger(

Int a=20;

Int b=30;

If(a>b)

APPLICATION_LOGS.debug(“pass”);

Else

APPLICATION_LOGS.debug(“fail”);

Once we prepare the log4J script, we need to execute the script. Once we run
the script log4j file will be creating along with the logs information.

JENKINS:- we are using JENKINS to scheduling scripts execution in selenium.


For working with JENKINS we need to download JENKINS.war file we need
to JENKINS through command prompt.
QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
114

JENKINS-> download->2.27 war file(weekly release)

Navigation:-

Open the browser

Enter the URL(https://jenkins.i01)

Click on enter

Click on download Jenkins

Click on 2.27.war file(now Jenkins.war file download into system)

Open the command prompt

Navigate the command prompt to Jenkins downloaded location

Write the value like below

Java – jar Jenkins.war(filename)

When we click on enter, Jenkins will be starting through command prompt.

Onece we start the Jenkins through cmd prompt. We can schedule the batches
through Jenkins configuration

(don’t close cmd window -> java – jar Jenkins.war)

Navigation:-

Starts the Jenkins by following above navigation

Open the browser type local host:8080

Click on enter(Now we can see getting started window)

Get the pwd by opening the location of pwd in browser

Paste into the pwd field

Click on continue(now all the plugins will be downloading)

Click on next

Click on start Jenkins

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
115

Register with Jenkins by providing user info

Click on next(now we can see Jenkins dashboard)

Click on new item

Specify the item name

Select free style project

Click on ok

Select build periodically under build triggers

Click on qtn mark

Specify the schedule(time to run the batch)

Select execute window batch command under build

Click on apply

Click on save

When we click on save button, all the batches information we can see in the
Jenkins dashboard.

Once the batches run through Jenkins, we can see the Jenkins batches info in the
dashboard of Jenkins and the history of the batches exefcution we can see in the
build history

Coverge page display ->EE->employer

Click on finish sp->spouse(wife)

Child covrge(in india parents also)

Issue case-> cm will login and issue the case

Generates the policy to all the employees

Reenrollment-> If we want to have more premium then we can use in another


year.

Pdf files generating to the all the employes

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur
116

Release-> 3-monhts

Functional & regression testing(Automated)

QSHORE 9030821111/9703921111
Experience the quality www.qshore.com https://www.facebook.com/qshoretech/
Gachibowli | Kondapur

Вам также может понравиться