Test Automation and Advanced Selenium-CombinedBook
Test Automation and Advanced Selenium-CombinedBook
Page 0-1
Test Automation & Advanced Selenium
Page 0-2
Test Automation & Advanced Selenium
Page 0-3
Test Automation & Advanced Selenium
Page 0-4
Test Automation & Advanced Selenium
Page 0-5
Test Automation & Advanced Selenium
Page 0-6
Test Automation & Advanced Selenium
Page 0-7
Test Automation & Advanced Selenium
Page 0-8
Test Automation & Advanced Selenium
Page 0-9
Test Automation & Advanced Selenium
Page 0-10
Test Automation & Advanced Selenium
Page 0-11
Test Automation & Advanced Selenium
Page 0-12
Test Automation & Advanced Selenium
Page 0-13
Test Automation & Advanced Selenium
Page 0-14
Test Automation & Advanced Selenium
Page 0-15
Test Automation & Advanced Selenium
Page 0-16
Test Automation & Advanced Selenium
Page 0-17
Test Automation & Advanced Selenium
Page 0-18
Test Automation & Advanced Selenium
Page 0-19
Test Automation & Advanced Selenium
Page 0-20
Test Automation & Advanced Selenium Introduction to Automation
Page 01-1
Test Automation & Advanced Selenium Introduction to Automation
Page 01-2
Test Automation & Advanced Selenium Introduction to Automation
Page 01-3
Test Automation & Advanced Selenium Introduction to Automation
Automation is the linking of disparate systems and software in such a way that they
become self-acting or self-regulating.
Page 01-4
Test Automation & Advanced Selenium Introduction to Automation
Page 01-5
Test Automation & Advanced Selenium Introduction to Automation
Page 01-6
Test Automation & Advanced Selenium Introduction to Automation
Page 01-7
Test Automation & Advanced Selenium Introduction to Automation
Page 01-8
Test Automation & Advanced Selenium Introduction to Automation
To execute the test case, we need to login to the application. We also need to check
if the user is already logged in or not. And the other we need to check is if the
logged in person is having access to “Add Users” or Not. If the above Two
Conditions are passed then we should execute the rest Else we should return the
test as failed.
Page 01-9
Test Automation & Advanced Selenium Introduction to Automation
Page 01-10
Test Automation & Advanced Selenium Introduction to Automation
Page 01-11
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-1
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-2
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-3
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-4
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-5
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-6
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-7
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-8
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-9
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-10
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-11
Test Automation & Advanced Selenium Introduction to Selenium
Page 02-12
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-1
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-2
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-3
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-4
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-5
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-6
Test Automation & Advanced Selenium Working With Selenium IDE
1.File Menu
It is very much analogous to the file menu belonging to any other application.
Export Test Case As and Export Test Suite give the liberty to the user to prefer
amid the available unit testing frameworks like jUnit, TestNG etc.
Thus an IDE test case can be exported for a chosen union of programming
language, unit testing framework and tool from the selenium package.
Page 03-7
Test Automation & Advanced Selenium Working With Selenium IDE
The Selenium IDE test cases can be saved into following format:
HTML format
The Selenium IDE test cases can be exported into following formats/programming
languages.
java (IDE exported in Java)
rb (IDE exported in Ruby)
py (IDE exported in Python)
cs (IDE exported in C#)
Page 03-8
Test Automation & Advanced Selenium Working With Selenium IDE
The Selenium IDE test cases can be saved into following format:
HTML format
The Selenium IDE test cases can be exported into following formats/programming
languages.
java (IDE exported in Java)
rb (IDE exported in Ruby)
py (IDE exported in Python)
cs (IDE exported in C#)
Page 03-9
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-10
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-11
Test Automation & Advanced Selenium Working With Selenium IDE
Log/Reference/UI-Element/Rollup Pane
The bottom pane is used for four different functions–Log, Reference, UI-Element,
and Rollup–depending on which tab is selected.
Log
When you run your test case, error messages and information messages showing
the progress are displayed in this pane automatically, even if you do not first select
the Log tab. These messages are often useful for test case debugging. Notice the
Clear button for clearing the Log. Also notice the Info button is a drop-down allowing
selection of different levels of information to log.
Reference
The Reference tab is the default selection whenever you are entering or modifying
Selenese commands and parameters in Table mode. In Table mode, the Reference
pane will display documentation on the current command. When entering or
modifying commands, whether from Table or Source mode, it is critically important
to ensure that the parameters specified in the Target and Value fields match those
specified in the parameter list in the Reference pane. The number of parameters
provided must match the number specified, the order of parameters provided must
match the order specified, and the type of parameters provided must match the type
specified. If there is a mismatch in any of these three areas, the command will not
run correctly.
While the Reference tab is invaluable as a quick reference, it is still often necessary
to consult the Selenium Reference document.
Page 03-12
Test Automation & Advanced Selenium Working With Selenium IDE
Action:
Used to change the state of the AUT(Application under Test)like click on some link,
type a value in edit box, select some options on the page, select a value from drop
down etc.
When action is performed on AUT the test will fail if the action is not achieved.
Accessor:
This command check the state of the application and save the application state in
some variable. It can be used for automatic generation of assertions.
Assertions:
Are very similar to checkpoint in UFT/QTP. Assertion verifies the state of the
application matches it with the expected state and generates the True/False result.
Page 03-13
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-14
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-15
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-16
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-17
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-18
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-19
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-20
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-21
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-22
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-23
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-24
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-25
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-26
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-27
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-28
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-29
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-30
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-31
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-32
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-33
Test Automation & Advanced Selenium Working With Selenium IDE
Page 03-34
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-1
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-2
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-3
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-4
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
1. Architecture
WebDriver's architecture is simpler than Selenium RC's.
Page 04-5
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
2. Speed
WebDriver is faster than Selenium RC since it speaks directly to the
browser uses the browser's own engine to control it.
3. Real-life Interaction
WebDriver interacts with page elements in a more realistic way. For
example, if you have a disabled text box on a page you were testing,
WebDriver really cannot enter any value in it just as how a real person
cannot.
• Selenium Core, just like other Javascript codes, can access disabled
elements. In the past, Selenium testers complain that Selenium Core
was able to enter values to a disabled text box in their tests. Differences
in API
4. API
Selenium RC's API is more matured but contains redundancies and often
confusing commands.
• For example, most of the time, testers are confused whether to use type
or typeKeys; or whether to use click, mouseDown, or mouseDownAt.
Worse, different browsers interpret each of these commands in different
ways tool
• WebDriver's API is simpler than Selenium RC's. It does not contain
redundant and confusing commands.
5. Browser Support
WebDriver can support the headless HtmlUnit browser
Page 04-6
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-7
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-8
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver
Page 04-9
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-1
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-2
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-3
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-4
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-5
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-6
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-7
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-8
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-9
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-10
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-11
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-12
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-13
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-14
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Click():
Click a link / button:
To click on an object through webdriver first we need to find out which locator we
are going to use. Is it ID, name, xpath, or css? For this purpose we can utilize
firebug / xpath checker to find out is there any id / name exists for the object we are
going to perform action upon. Then write the code as below:
driver.findElement(By.xpath("//a[@href='CustomerInfo.htm']")).click();
In the above line of code “driver” could be FirefoxDriver, InternetExplorerDriver,
ChromeDriver, HtmlUnitDriver, etc. On one of these browsers we are going to find
an element and then click as per the code.
findElement is an API provided by the webdriver which requires argument
“By.xpath”. The “xpath” can be replaced by one of the below methods if we need to
identify the element with any other attributes such as css, name, classname, etc.
Page 05-15
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Click():
Click a link / button:
To click on an object through webdriver first we need to find out which locator we
are going to use. Is it ID, name, xpath, or css? For this purpose we can utilize
firebug / xpath checker to find out is there any id / name exists for the object we are
going to perform action upon. Then write the code as below:
driver.findElement(By.xpath("//a[@href='CustomerInfo.htm']")).click();
In the above line of code “driver” could be FirefoxDriver, InternetExplorerDriver,
ChromeDriver, HtmlUnitDriver, etc. On one of these browsers we are going to find
an element and then click as per the code.
findElement is an API provided by the webdriver which requires argument
“By.xpath”. The “xpath” can be replaced by one of the below methods if we need to
identify the element with any other attributes such as css, name, classname, etc.
Page 05-16
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Clear();
The clear() method executes an "Automation Atom", which is a JavaScript
function intended to provide the smallest basic unit of automation
functionality for a browser. In the case of clear(), that function sets the
value property of the element to an empty string (''), then fires the
onchange event on the element. The atoms function you're interested in is
bot.action.clear()
click
clear
sendKeys
submit
Select – selectByVisibleText etc.
getText
getAttribute
Page 05-17
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-18
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-19
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-20
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-21
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Simple alert
Simple alerts just have a OK button on them. They are mainly used to display some
information to the user.
Confirmation Alert
This alert comes with an option to accept or dismiss the alert. To accept the alert
you can use Alert.accept() and to dismiss you can use the Alert.dismiss().
Prompt Alerts
In prompt alerts you get an option to add text to the alert box. This is specifically
used when some input is required from the user. We will use
the sendKeys() method to type something in the Prompt alert box.
Page 05-22
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Window A has a link "Link1" and we need to click on the link (click event).
Window B displays and we perform some actions.
Page 05-23
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Alerts are different from regular windows. The main difference is that alerts are
blocking in nature. They will not allow any action on the underlying webpage if they
are present. So if an alert is present on the webpage and you try to access any of
the element in the underlying page you will get following exception:
UnhandledAlertException: Modal dialog present
Page 05-24
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-25
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
1. Unconditional
2. Conditional Synchronization
Unconditional :
In this we just specify timeout value only. We will make the tool to wait until certain
amount of time and then proceed further.
Examples: Wait() and Thread.Sleep();
The main disadvantage for the above statements are, there is a chance of
unnecessary waiting time even though the application is ready.
The advantages are like in a situation where we interact for third party systems like
interfaces, it is not possible to write a condition or check for a condition. Here in this
situations, we have to make the application to wait for certain amount of time by
specifying the timeout value.
Conditional Synchronization:
We specify a condition along with timeout value, so that tool waits to check for the
condition and then come out if nothing happens.
It is very important to set the timeout value in conditional synchronization, because
the tool should proceed further instead of making the tool to wait for a particular
condition to satisfy.
Page 05-26
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-27
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-28
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-29
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-30
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-31
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-32
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-33
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-34
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Page 05-35
Test Automation & Advanced Selenium Testing Web Applications Using Web Driver API
Answer 1:
True
Answer 2:
Javascript
Page 05-36
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-1
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-2
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-3
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-4
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-5
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-6
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-7
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-8
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-9
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-10
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-11
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-12
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-13
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-14
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-15
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-16
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-17
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-18
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-19
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-20
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-21
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-22
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-23
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-24
Test Automation & Advanced Selenium Web Driver Test with Xunit
Example:
The class above is a placeholder for the suite annotations, no other implementation
is required.
Note : @RunWith annotation, which specifies that the JUnit 4 test runner to use is
org.junit.runners.Suite for running this particular test class. This works in
conjunction with the @Suite annotation, which tells the Suite runner which test
classes to include in this suite and in which order.
Page 06-25
Test Automation & Advanced Selenium Web Driver Test with Xunit
We need to specify the class names along with packages in between the classes
tags.
All the classes specified in the xml will get executes which have TestNG
annotations.
Page 06-26
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-27
Test Automation & Advanced Selenium Web Driver Test with Xunit
Page 06-28
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-1
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-2
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-3
Test Automation & Advanced Selenium Selenium Web Driver – Advance
1. Architecture
WebDriver's architecture is simpler than Selenium RC's.
Page 07-4
Test Automation & Advanced Selenium Selenium Web Driver – Advance
2. Speed
WebDriver is faster than Selenium RC since it speaks directly to the
browser uses the browser's own engine to control it.
3. Real-life Interaction
WebDriver interacts with page elements in a more realistic way. For
example, if you have a disabled text box on a page you were testing,
WebDriver really cannot enter any value in it just as how a real person
cannot.
• Selenium Core, just like other Javascript codes, can access disabled
elements. In the past, Selenium testers complain that Selenium Core
was able to enter values to a disabled text box in their tests. Differences
in API
4. API
Selenium RC's API is more matured but contains redundancies and often
confusing commands.
• For example, most of the time, testers are confused whether to use type
or typeKeys; or whether to use click, mouseDown, or mouseDownAt.
Worse, different browsers interpret each of these commands in different
ways tool
• WebDriver's API is simpler than Selenium RC's. It does not contain
redundant and confusing commands.
5. Browser Support
WebDriver can support the headless HtmlUnit browser
Page 07-5
Test Automation & Advanced Selenium Selenium Web Driver – Advance
1. Architecture
WebDriver's architecture is simpler than Selenium RC's.
Page 07-6
Test Automation & Advanced Selenium Selenium Web Driver – Advance
2. Speed
WebDriver is faster than Selenium RC since it speaks directly to the
browser uses the browser's own engine to control it.
3. Real-life Interaction
WebDriver interacts with page elements in a more realistic way. For
example, if you have a disabled text box on a page you were testing,
WebDriver really cannot enter any value in it just as how a real person
cannot.
• Selenium Core, just like other Javascript codes, can access disabled
elements. In the past, Selenium testers complain that Selenium Core
was able to enter values to a disabled text box in their tests. Differences
in API
4. API
Selenium RC's API is more matured but contains redundancies and often
confusing commands.
• For example, most of the time, testers are confused whether to use type
or typeKeys; or whether to use click, mouseDown, or mouseDownAt.
Worse, different browsers interpret each of these commands in different
ways tool
• WebDriver's API is simpler than Selenium RC's. It does not contain
redundant and confusing commands.
5. Browser Support
WebDriver can support the headless HtmlUnit browser
Page 07-7
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-8
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-9
Test Automation & Advanced Selenium Selenium Web Driver – Advance
GhostDriver is the project that provides the code that exposes the WebDriver API
for use within PhantomJS.
PhantomJS bakes the GhostDriver code into itself, and ships it as part of its
downloadable executable.
Thus, to use "GhostDriver" with PhantomJS, only PhantomJS is needed.
Page 07-10
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Native apps are those written using the iOS or Android SDKs.
Mobile web apps are web apps accessed using a mobile browser (Appium supports
Safari on iOS and Chrome or the built-in 'Browser' app on Android). Hybrid apps
have a wrapper around a "webview" -- a native control that enables interaction with
web content. Projects like Phonegap, make it easy to build apps using web
technologies that are then bundled into a native wrapper, creating a hybrid app.
You shouldn't have to recompile your app or modify it in any way in order to
automate it.
You shouldn't be locked into a specific language or framework to write and run your
tests.
A mobile automation framework shouldn't reinvent the wheel when it comes to
automation APIs.
A mobile automation framework should be open source, in spirit and practice as
well as in name.
Page 07-11
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-12
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-13
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-14
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-15
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-16
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-17
Test Automation & Advanced Selenium Selenium Web Driver – Advance
Page 07-18
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-1
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-2
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-3
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-4
Test Automation & Advanced Selenium Selenium Frameworks
1. Architecture
WebDriver's architecture is simpler than Selenium RC's.
Page 08-5
Test Automation & Advanced Selenium Selenium Frameworks
2. Speed
WebDriver is faster than Selenium RC since it speaks directly to the
browser uses the browser's own engine to control it.
Selenium RC is slower since it uses a Javascript program called
Selenium Core. This Selenium Core is the one that directly controls
the browser, not you.
3. Real-life Interaction
WebDriver interacts with page elements in a more realistic way. For
example, if you have a disabled text box on a page you were testing,
WebDriver really cannot enter any value in it just as how a real
person cannot.
Selenium Core, just like other Javascript codes, can access disabled
elements. In the past, Selenium testers complain that Selenium Core
was able to enter values to a disabled text box in their tests.
Differences in API
4. API
Selenium RC's API is more matured but contains redundancies and
often confusing commands.
For example, most of the time, testers are confused whether to use
type or typeKeys; or whether to use click, mouseDown, or
mouseDownAt. Worse, different browsers interpret each of these
commands in different ways tool
WebDriver's API is simpler than Selenium RC's. It does not contain
redundant and confusing commands.
5. Browser Support
WebDriver can support the headless HtmlUnit browser
HtmlUnit is termed as "headless" because it is an invisible browser -
it is GUI-less.
It is a very fast browser because no time is spent in waiting for page
elements to load. This accelerates your test execution cycles.
Since it is invisible to the user, it can only be controlled through
automated means.
Selenium RC cannot support the headless HtmlUnit browser. It needs
a real, visible browser to operate on.
Page 08-6
Test Automation & Advanced Selenium Selenium Frameworks
1.File Menu
It is very much analogous to the file menu belonging to any other application.
Export Test Case As and Export Test Suite give the liberty to the user to prefer
amid the available unit testing frameworks like jUnit, TestNG etc.
Thus an IDE test case can be exported for a chosen union of programming
language, unit testing framework and tool from the selenium package.
Page 08-7
Test Automation & Advanced Selenium Selenium Frameworks
The Selenium IDE test cases can be saved into following format:
HTML format
The Selenium IDE test cases can be exported into following formats/programming
languages.
java (IDE exported in Java)
rb (IDE exported in Ruby)
py (IDE exported in Python)
cs (IDE exported in C#)
Page 08-8
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-9
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-10
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-11
Test Automation & Advanced Selenium Selenium Frameworks
The Selenium IDE test cases can be saved into following format:
HTML format
The Selenium IDE test cases can be exported into following formats/programming
languages.
java (IDE exported in Java)
rb (IDE exported in Ruby)
py (IDE exported in Python)
cs (IDE exported in C#)
Page 08-12
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-13
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-14
Test Automation & Advanced Selenium Selenium Frameworks
Log/Reference/UI-Element/Rollup Pane
The bottom pane is used for four different functions–Log, Reference, UI-Element,
and Rollup–depending on which tab is selected.
Log
When you run your test case, error messages and information messages showing
the progress are displayed in this pane automatically, even if you do not first select
the Log tab. These messages are often useful for test case debugging. Notice the
Clear button for clearing the Log. Also notice the Info button is a drop-down
allowing selection of different levels of information to log.
Reference
The Reference tab is the default selection whenever you are entering or
modifyingSelenese commands and parameters in Table mode. In Table mode, the
Reference pane will display documentation on the current command. When
entering or modifying commands, whether from Table or Source mode, it is critically
important to ensure that the parameters specified in the Target and Value fields
match those specified in the parameter list in the Reference pane. The number of
parameters provided must match the number specified, the order of parameters
provided must match the order specified, and the type of parameters provided must
match the type specified. If there is a mismatch in any of these three areas, the
command will not run correctly.
While the Reference tab is invaluable as a quick reference, it is still often necessary
to consult the Selenium Reference document.
Page 08-15
Test Automation & Advanced Selenium Selenium Frameworks
Accessor:-
This command check the state of the application and save the application state in
some variable. It can be used for automatic generation of assertions.
Assertions:
Are very similar to checkpoint in UFT/QTP. Assertion verifies the state of the
application matches it with the expected state and generates the True/False result.
Page 08-16
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-17
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-18
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-19
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-20
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-21
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-22
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-23
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-24
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-25
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-26
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-27
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-28
Test Automation & Advanced Selenium Selenium Frameworks
Page 08-29
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 1 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 2 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
Table of Contents
Document Revision History ................................................................................................ 2
Table of Contents ............................................................................................................... 3
Getting Started ................................................................................................................... 4
Lab Demo 1: Example (Basic Selenium IDE Flow) ............................................................ 5
Lab Demo: Example (Selenium IDE) (Cont.…) .................................................................. 6
Lab Demo: Example (Selenium IDE) (Cont.…) .................................................................. 7
Lab Demo 2: Learning Selenium IDE (Modifications) ........................................................ 8
Lab 1. Learning Selenium IDE(Basic Flow) .................................................................... 9
Lab 2. Learning Selenium IDE(Performing Validations) ............................................... 10
Lab 3. Create a new account (using Selenium Webdriver) .......................................... 11
Lab 4. Validations in Selenium (using Selenium Webdriver) ........................................ 13
Lab 5. Alert and window handling (using Selenium Webdriver) ................................... 14
Lab 6. WebDriver with JUnit/TestNG (using Selenium Webdriver with Junit and
TestNG) 15
Lab 7. Advance Selenium (Chrome Driver and IE Driver) ............................................ 16
Lab 8. Advance Selenium (RemoteWebDriver)............................................................ 17
Appendices ....................................................................................................................... 18
Appendix A: Selenium Standards ........................................................................ 18
The information contained in this document is proprietary and confidential. For Capgemini only. | 3 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
Getting Started
Overview
This lab book is a guided tour for learning Test Automation & Advanced Selenium. It
comprises solved examples and ‘To Do’ assignments. Follow the steps provided in the
solved examples and work out the ‘To Do’ assignments given.
Instructions
For all coding standards refer Appendix A. All lab assignments should refer
coding standards.
Create a directory by your name in drive <drive>. In this directory, create a
subdirectory Selenium_Assign. For each lab exercise create a directory as
lab <lab number>.
The information contained in this document is proprietary and confidential. For Capgemini only. | 4 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 5 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 6 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
Perform operations on
the web page
Play
Button
The information contained in this document is proprietary and confidential. For Capgemini only. | 7 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
Time 60 minutes
2. In order to add new command, go to the command where the new command needs to be added
and then do right click , click on ‘Insert New Command’
The information contained in this document is proprietary and confidential. For Capgemini only. | 8 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 9 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 10 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
Goals Understanding the scenario from end to end and automating the same
Analyze the requirement and perform validations accordingly
Time 120 minutes
Please ensure that the variables have to be defined before it is being used.
1. Enter 'Address 1' which should contain characters between 3 and 128
The information contained in this document is proprietary and confidential. For Capgemini only. | 11 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 12 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
After login on the ‘Open Cart’, create a test script following the below
mentioned steps:
The information contained in this document is proprietary and confidential. For Capgemini only. | 13 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
The information contained in this document is proprietary and confidential. For Capgemini only. | 14 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
1. Consider the flow mentioned in Lab 3 & Lab 4, complete the task using Selenium
WebDriver and JUnit.
[NOTE: All the verifications should be using JUnit Assertions]
2. Consider the flow mentioned in Lab 3 & Lab 4, complete the task using Selenium
WebDriver and TestNG.
[NOTE: All the verifications should be using TestNG Assertions. Testcases
should have proper TestNG Reporter logging as well.]
3. Create one TestNG test suite for both the testcases created for question
number 2 along with testing.xml and execute the test suite. Provide the
Reports as well.
The information contained in this document is proprietary and confidential. For Capgemini only. | 15 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
1. Consider the flow mentioned in Lab 3 & Lab 4, make necessary changes to
execute the same flow on both Chrome and Internet Explorer browser.
The information contained in this document is proprietary and confidential. For Capgemini only. | 16 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
1. Consider the flow mentioned in Lab 3 & Lab 4, make necessary changes to
execute the same flow using RemoteWebDriver and Selenium Grid on Firefox,
Chrome and Internet Explorer browser.
[NOTE: Set Platform, BrowserName and Version to DesiredCapabilities]
2. Consider the flow mentioned in Lab 4 and take screenshot after each steps.
Save all the screenshots inside a folder called ‘Screenshots’ in the root of the
Java project.
The information contained in this document is proprietary and confidential. For Capgemini only. | 17 / 18
TEST AUTOMATION & ADVANCED
SELENIUM LAB BOOK
Appendices
For each of the above, please follow coding conventions specified by that technology.
Sometimes you are going to have to break rules and use non-standard syntax for good
reason. Try to keep this to the minimum.
See the W3C site for more information on locator types and keyword statements.
The important thing to remember is that proper keywords are essential to assist validation
software in checking your document.
Use Selenium IDE to find the locators for the elements.
Refer to W3C for technical and syntax information.
Always use the comments with the codes for proper understanding.
The information contained in this document is proprietary and confidential. For Capgemini only. | 18 / 18