0% found this document useful (0 votes)
56 views29 pages

Booooo

This document provides an overview of advanced Selenium testing tool training. It covers topics like Selenium IDE, RC, WebDriver, locators, object identification, and sample code. The training uses a real-world approach and end-to-end framework to teach automation strategy, Selenium components, recording and playback, and real testing scenarios.

Uploaded by

ansar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views29 pages

Booooo

This document provides an overview of advanced Selenium testing tool training. It covers topics like Selenium IDE, RC, WebDriver, locators, object identification, and sample code. The training uses a real-world approach and end-to-end framework to teach automation strategy, Selenium components, recording and playback, and real testing scenarios.

Uploaded by

ansar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

Automation

using Selenium
Advanced Level Real-Time
Training in SELENIUM Testing
Tool

Content of
Selenium

Introduction

to Testing
Test - Automation
Introduction
Test-Automation Strategy
Overview of Selenium
Components
Selenium IDE & RC
Selenium Web driver 2.0
Selenium Grid
Object Identification
XPATH, Object Locators

Approach & Importance in TestAutomation


Record

& Play back its not a Complete


Automation Testing.

Automation

Strategy & Framework is


important in Test-Automation Projects.

End

to End Framework based Training


with Real time Scenarios.

Automation Introduction
Automation

is the integration of testing tools


into the test environment in such a manner that
the test execution, logging, and comparison of
results are done with little human intervention.

testing tool is a software application which


helps automate the testing process. But the
testing tool is not the complete answer for
automation.

Process of Automatio
Unstable

software: If the software is still


under development and undergoing many
changes automation testing will not be that
effective.
Once in a blue moon test scripts: Do not
automate test scripts which will be run
once in a while.
Code and document review: Do not try to
automate code and document reviews; they
will just cause trouble.

Features of Automation
Testing

workbenches provide a range of tools


to reduce the time required and total testing
costs.
Systems such as Nunit support the automatic
execution of tests.
Most testing workbenches are open systems
because testing needs are organisation-specific.
They are sometimes difficult to integrate with
closed design and analysis workbenches.

Advantages of Automation
Testing

Automated testing is cheaper.


Automated testing is faster.

Automated testing is more reliable.


Automated testing reduces human
and technical risks.
Automated testing is more powerful
and versatile.

Selenium Introduction
Test

tool for web applications


Runs in any mainstream browser
Supports tests in many languages
Selenium(pure HTML, no backend
required)
Java, C#, Perl, Python, Ruby
Record/playback (Selenium IDE)
Open Source with corporate
backing
Lives at selenium.openqa.org

What is Selenium?
Selenium

automates browsers.
Selenium has the support of some
of the largest browser vendors who
have taken (or are taking) steps to
make Selenium a native part of
their browser.
It is also the core technology in
countless other browser automation
tools, APIs and frameworks.

Why selenium?
Selenium is probably the best option
for automated testing of Websites
today.

It is becoming increasingly popular


and it is the first choice of automation
testers as well as organizations for
automating the testing of Web-based
applications for both the GUI as well as
the functionality.

Selenium can also be used as a unit


testing tool for JavaScript

You

can use opensource.Selenium


tool selenium IDE is a plugin to
firefox to record and playback
tests (like WinRunner, QTP).
You can then export the recorded
test in most language e.g. html,
Java , .net , perl , ruby etc. The
exported test can be run in any
browser and any platform using
selenium remote control.

The

following graph shows the


popularity of Selenium along with
other open source automation
testing tools.

Advantages of Selenium
Free!
Can

test across multiple browsers


Mimics actual user experience
Ajax / CSS support
Use language of choice
Large user community

Overview of Selenium
Components
Selenium IDE - Plugin to Firefox to record and play
test in firefoxand also export tests in different
languages.
Selenium RC- Allows playing of exported test in
different platform/OS.
Selenium Grid -Allows to control lots of selenium
machines.
Selenium Web driver 2.0-Driving a browser natively
as a user would either locally or on a remote
machine using the Selenium Server it marks a leap
forward in terms of browser automation.

Selenium IDE
Easy

record and playback.


Intelligent field selection will use IDs, names, or
XPath as needed.
Autocomplete for all common Selenium commands.
Walk through tests.
Debug and set breakpoints.
Save tests as HTML, Ruby scripts, or any other
format. Support for Selenium user-extensions.js file.
Option to automatically assert the title of every
page.

Selenium IDE
Firefox
Easy
Not

extension

record and playback

just a recorder

Intelligent

field selection
will use IDs, names,
or XPath as needed

Selenium IDE
Auto-complete

for all
common Selenium
commands

Walk

through tests

Debug

and set
breakpoints

Save

tests as HTML,
Ruby scripts, or any
other format

Selenium Web driver


Selenium

Web Driver accepts commands


(sent in Selenese, or via a Client API) and
sends them to a browser.
This is implemented through a browserspecific browser driver, which sends
commands to a browser, and retrieves
results.
Most browser drivers actually launch and
access a browser application (such as
Firefox or Internet Explorer).

Unlike

in Selenium 1, where the Selenium


RC server was necessary to run tests,
Selenium Web Driver does not need a special
server to execute tests.
Instead, the Web Driver directly starts a
browser instance and controls it. However,
Selenium Grid can be used with Web Driver
to execute tests on remote systems.

Selenium IDE

Selenium RC

Webdriver

Works only on
mozilla

Works on almost all


browsers.Does not
work on latest
version of firefox/IE

Works on latest
versions of almost
all browsers Firefox, IE(6,7,8),
OPera, Chrome

Record and run


tool

No Record and run

No Record and run

No server required
to start

Server is required to
start

No server required
to start

Core engine is
Javascript based

Core engine is
Javascript based

Interacts natively
with browser
application

Very simple to use.

Its a simple and small API

Complex and a bit


large API as
compared to RC

Not at all object


oriented

Less Object orinted


API

Purely Object
oriented API

Cannot move
mouse with it

Cannot move mouse Can move mouse


with it
cursor

Full xpaths have to


be appended with

Full xpaths have to


be appended with

No need to append
'xpath=\\'

Object Identification
To

identify the objects such as Links,


Buttons, Edit boxes, Drop downs, etc on the
applicationSelenium uses a concept called
Locators.
There are around 8 different types of
locators.
Out of them, explaining only four as they
are widely used while automating the test
cases using Selenium.
1.id=

id By default Selenium IDE takes


id as Locator
Every Web Page will be having some
HTML Source code. This can be viewed
using View > Page Source / View source

Locators
Element Locators
ID: id=foo
Name: name=foo
First ID, then name: identifier=foo
DOM:
document.forms[myform].myDropdown
XPath:
xpath=//table[@id='table1']//tr[4]/td[2]
Link Text: link=sometext
CSS Selector: css=a[href=#id3]
Sensible defaults, e.g. xpath if starts with //
selenium.click("btnG");

Sample Codings of
Selenium
driver. get("http://www.google.com");To open an
application

driver.findElement(By.id("passwd-id"));Finding
Element using Id
driver.findElement(By.name("passwd"));Finding
Element using Name
driver.findElement(By.
Xpath("//input[@id=passwd-id]"));Finding
Element using Xpath
element.sendKeys("some text");To type some data
element. clear();clear the contents of a text field or
text area
driver.findElement(By. Xpath("//select"));Selecting
the value

driver.switchTo().window("window Name");Moving
from one window to another window
driver.switchTo().frame("frame Name");swing from
frame to frame (or into iframes)
driver.switchTo().frame("frameName.0.child");to
access sub frames by separating the path with a dot,
and you can specify the frame by its index too.
driver.switchTo().alert();Handling Alerts
driver.
Navigate().to("http://www.example.com");To
Navigate Particular URL
driver. Navigate().forward();To Navigate Forward
driver. Navigate().back();To Navigate Backward

driver. Quit()Quits the driver and closes every


associated window.
driver.switch_to_alert()Switches focus to an alert on
the page.
driver. Refresh()Refreshes the current page
driver.get_screenshot_as_file('/Screenshots/foo.p
ng')The full path you wish to save your screenshot to
driver.get_screenshot_as_base64()Gets the
screenshot of the current window as a base64 encoded
string
select.findElements(By.tagName("option"));Select
ing the value
select.deselectAll();This will deselect all OPTIONs
from the first SELECT on the page

You might also like