Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Selenium and WebDriver (full)

Where prezi excels - Create using frames - Check your overview - Use a Path - Nonlinear discussions

Evgeny Tkachenko

on 11 June 2012

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Selenium and WebDriver (full)

What is Selenium?
The name comes from the Greek σελνη selene meaning "Moon"
My first project.
Figures from the project
I conducted a market analysis
Begin to automate - it's easy!
Selenium occurs in three distinct forms: as a non-crystalline (gray);
it can form
as a deep
red to black
powder; and it can form as red crystals.
Selenium is a chemical element with atomic number 34, chemical symbol Se, and an atomic mass of 78.96. It is a nonmetal, whose properties are intermediate between those of adjacent chalcogen elements sulfur and tellurium.
In nature
In testing
The tests can then be run against most modern web
browsers. Selenium deploys on
Windows, Linux,
and Macintosh platforms.
History of successful automation
1 huge project
2 components:
- A social part (like "Facebook")
- An educational part(more than 15 interconnected modules)
Multiplying by quantity of roles in a project teaching department (heads, teachers, students)
Multiplying by quantity of roles in a social part of the project (managers, moderators, founders of communities and groups, ordinary participants)
Plus, a control system of a project content
QA-team consisted of
2 people
I was responsible for
for interaction with a development team
for regression testing of the entire project
for interaction with a team of designers and web technicians
for tasks' distribution within the "team" testers
At first I was alone...
I was face to face with a huge project
Regression testing took more than
7 days
The whole 7 days!!!
Finally we did release it with live bugs
At first it was like this...
then something like this...
and ended up looking like this...
Detected about 100 of bugs
Fix them all before the release was not possible, and finally ...
But I didn't despair ...
Reading regular article, I stumbled on an automation tool Selenium
3 years ago, "googling" the word "Selenium", I got something like the following ...
1. I started studying the question by myself, spending weekends at work
2. Two months later the first serious methods and tests were ready
3. I showed the results to my boss
4. I was asked to review the market of automation tools
Leaders in the market
i made a report
at first it was so ...
It turned out that...
Thank you!
Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Java, Groovy, Perl, PHP, Python and Ruby.
and even...
3 years ago, when I worked for another company, I had a project
... nevertheless it was possible to find something helpful
We had chosen ...
I studied all the documentation.
I looked through all the articles, blogs, forums.
as a result, regression testing became ...

- and how somebody else works ...
В презентации использовались картинки с сайтов:
Absolutely alone
7.WebDriver is on its way to
becoming a browser standard.
What is it?
What does it do?
WebDriver is a tool for automating testing web applications, and in particular to verify that they work as expected. It aims to provide a friendly API that's easy to explore and understand, which will help make your tests easier to read and maintain. It's not tied to any particular test framework, so it can be used equally well with JUnit, TestNG or from a plain old "main" method.
And then?!
And what's the difference between
WebDriver and Selenium?
The main difference is hidden in the architecture of these tools
Let's look at these differences
a bit more closely!
Here the presentation comes to an end...
5. Window
An interface for managing size and
position of window browser
Interface WebDriver
The main interface used for testing, which represents an idealised web browser.

The methods in this class fall into three categories:
- Control of the browser itself (get(), navigate(), close(), etc)

- Selection of WebElements (findElement(), findElements(), etc)

- Debugging aids (getCurrentUrl(), getPageSource(), getWindowHandles(), etc)
WebDriver has six major Interfaces :
0. ImeHandler
An interface for managing input methods
1. Navigation
Used to move between sites in the current window
2. Options
An interface for managing stuff you would do in a browser menu
3. TargetLocator
Used to locate a given frame or window
4. Timeouts
An interface for managing timeout behavior for WebDriver instances.
Let's start!
Locating UI Elements
2. Once you’ve finished filling out the form, you probably want to submit it. One way to do this is would be to find the “submit” button and click it:

Alternatively, WebDriver has the convenient "submit" method on every element:

Select multiple items


WebElement item1 = driver.findElement(By.xpath("//li[.='Item 1']"));
WebElement item2 = driver.findElement(By.xpath("//li[.='Item 2']"));

//First, configure it:
Actions builder = new Actions(driver);
.click() ;

//Then get the action:
Action selectMultiple = builder.build();

//And execute it:
Tips, Hacks & Hidden Features
WebDriver supported Javascript alerts

// Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert();

// Get the text of the alert or prompt

// And acknowledge the alert (equivalent to clicking "OK")
Drag And Drop
Drag an element to an offset

WebElement dragItem = driver.findElement(By.id("draggable"));
(new Actions(driver)).dragAndDropBy(dragItem, 5, 10).build().perform();
Press control+...

textBox.sendKeys(Keys.LEFT_CONTROL + "a");
textBox.sendKeys(Keys.LEFT_CONTROL + "c");
textBox.sendKeys(Keys.LEFT_CONTROL + "v");
textBox.sendKeys(Keys.LEFT_CONTROL, Keys.F5);
Sequence of actions
Proxy configuration

Proxy proxy = new Proxy();
DesiredCapabilities capabilities =
capabilities.setCapability(CapabilityType.PROXY, proxy);
Scrolls a window
It is possible to use Javascript execution abilities:

int pixel = 500;
((JavascriptExecutor) driver)
.executeScript("if (window.screen){window.scrollBy(0," + pixel + ");};");
Start Firefox with an extension installed
File file = new File("firebug-1.9.0-fx.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(firefoxProfile);

This is the most efficient and prefered way to locate an element. Common pitfalls that UI developers make is having non-unique id’s on a page or auto-generating the id, both should be avoided. A class on an html element is more appropriate than an auto-generated id.

WebElement captchaBox = driver.findElement(By.id("ConfirmMainEmailForm_captcha"));
By Name

Finds the element with matching name attribute.

WebElement captchaBox = driver.findElement(By.name("ConfirmMainEmailForm[captcha]"));
By Link Text

Find the link element with matching visible text.

WebElement signInButton =
driver.findElement(By.linkText("Sign in and register"));
By Partial Link Text

Find the link element with partial matching visible text.

WebElement signInButton =
driver.findElement(By.partialLinkText("Sign in"));

Like the name implies it is a locator strategy by css.
Please,beware that not all browsers were created equal, some css that may work in one version - may not work in another.

WebElement signInButton = driver.findElement(By.cssSelector(".bUserBar .LikeRealBtn"));

At a high level, WebDriver uses a browser’s native XPath capabilities wherever possible.

List<WebElement> radioButtons =
List<WebElement> radioButtonsVisible = driver.findElements(By.xpath("//input[@class='bTicketPaper__eRadioButton' and not(@disabled='disabled')]"));
Let's solve the problem:
Find all radio buttons circled in the picture
The same result we get if we use as a locator class name.

By Class Name

“Class” in this case refers to the attribute on the DOM element. Often in practicle use there are many DOM elements with the same class name, thus finding multiple elements becomes the more pratical option over finding the first element.

List<WebElement> radioButtons =
I almost forgot ...
By Tag Name

The DOM Tag Name of the element.

Let's resolve the issue: How do We get the entire text of the page?
WebElement bodyOfPage = driver.findElement(By.tagName("body"));
String bodyText = bodyOfPage.getText();
0. Locating UI Elements
Each of the language bindings expose a “Find Element” and “Find Elements” method.

The “Find” methods take a locator or query object called “By”. “By” strategies are listed further.
1. Typing into an element
If you want to enter some text into a text field, then you can use:

element.sendKeys("some text");

A side-effect of this is that typing something into a text field won’t automatically clear it.
Instead, what you type will be appended to what’s already there. You can easily clear the contents of a text field or textarea:

Work with a slider

WebElement dragItem =
driver.findElement(By.xpath("//a[@class='ui-slider-handle ui-state-default ui-corner-all']"));
(new Actions(driver)).dragAndDropBy(dragItem, 10, 0).build().perform();
Drag an element to drop on to another element

WebElement fromItem1 = driver.findElement(By.id("draggable"));
WebElement toItem2 = driver.findElement(By.id("droppable"));
(new Actions(driver)).dragAndDrop(fromItem1, toItem2).build().perform();
Executing JavaSript

WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("alert('Selenium1 bye-bye')");
1. Selenium works through proxy using Javascript.
1. WebDriver works natively with Browser
(Native automation faster and a little less
prone to error and browser configuration).

2. Selenium supports major browsers.
(IE, Firefox, Chrome, Safari, Opera)
2. WebDriver supports IE, Firefox, Opera,
Chrome, and also Android and IPhone Drivers.
3. Selenium API is quite complicated
3. Great Simple API.
4. Selenium supports multiple
languages to write the test.
(C#, Java, Groovy, Perl, PHP,
Python and Ruby)
4. Perl and PHP are not supported in WebDriver
(December 2011).
A pure JS API support is also in the planning stage.
5. Selenium-RC Server's start-up
is required.

5. Does not Requires Selenium-RC Server
to be running.
6. Access to headless HTMLUnit
can allow really fast tests.
Bugs are found by tests, not by automation
Can infinitely look at three things:
- how the fire burns,
- how the water flows
Presentation Agenda
1. Test Automation.
When you are face to face with
a huge project
0. What is Selenium?
2. Comparison:
Selenium RC vs WebDriver
3. Interface WebDriver.
Tips, Hacks & Hidden Features
4. Migrating from
Selenium RC to WebDriver
The most important Commands
and Operations...
Also, you can simulate pressing the arrow keys by using the “Keys” class:

element.sendKeys("s", Keys.ARROW_DOWN);

It is possible to call sendKeys on any element, which makes it possible to test keyboard shortcuts such as those used in GMail.
WebElement loginElement = driver.findElement(By.name("AuthForm[loginOrEmail]"));

driver.findElement(By.xpath("//input[contains(@value,'Sign in')]")).click();
Evgeny Tkachenko
Test Manager
Evgeny Tkachenko
Senior Software Automation Testing Engineer
What should you do to start your
career in automated testing?
So, from my own experience, to start your career in automated testing I suggest you do the following three things:
Do not wait for the "kick from the leadership", act!
Read all that you can!
Get some hands on experience in using
automated testing tools!
our blog:
How to migrate to WebDriver ?
Just "to Cut off"
//Get the screen size
java.awt.Dimension screenSize =

//Define the desired size
Dimension maxWindowSize =
new Dimension(screenSize.width -4, screenSize.height-4);

//Set the desired size
WebDriver.Window window = driver.manage().window();
WebDriver. Hidden Features.
Maximize the window
Just start to use WebDriver API.
But you need to rework all your methods in one massive push...
Begin to automate - it's easy!
WebDriver. Hidden Features.
Use WebDriver-Backed Selenium-RC...
The Java version of WebDriver provides an implementation of the Selenium-RC API.
This means that you can use the underlying WebDriver technology using the Selenium-RC API.
File profileDir = new File("SeleniumProf");
FirefoxProfile firefoxProfile = new FirefoxProfile(profileDir);
WebDriver driver = new FirefoxDriver(firefoxProfile);
Full transcript