SlideShare a Scribd company logo
1 of 72
Download to read offline
Selenium Clinic

Alan Richardson (@eviltester), Simon Stewart (@shs96c)

www.eurostarconferences.com

@esconfs
#esconfs
What Is This?
These slides were used in the “Best Tutorial”
Award winning tutorial from Eurostar 2012
hosted by Simon Stewart and Alan
Richardson
Most of these slides form part of the slide
deck for Alan Richardson's Online Course

http://unow.be/at/webdriverapi
So if you like what you read here – check out the full 18+ hour
tutorial with 200+ slides
Selenium Conference
Do you with there was a conference
dedicated to all things Selenium?
Well there is:
http://www.seleniumconf.org/
It may be happening soon. It may be near
you. Check the site for more details.
Source Code
The source code developed during the tutorial
and in preparation for the tutorial can be
found on github:
https://github.com/shs96c/selenium_clinic
Tutorial Agenda
Clinic ('klinik)
1. A tutorial, often associated with a
conference that is devoted to the
discussion of a single tool
2. A group session, often led by bearded
gentlefolk, which offers hints and tips,
points out oft neglected practices, and may
offer practical hands on challenges
3. A place where such instruction occurs
A Short History of Selenium
“All Selenium trainers, are mandated* to provide a
short history of Selenium where they describe
Selenium (including WebDriver & Selenium-RC &
grid etc.), they must also provide a brief history.”
* it is a tradition or a law or an old charter or something
Selenium-RC

WebDriver

7
Intro & Capabilities


Hello from Alan & Simon



Current Group Capabilities
My First WebDriver Test

9
What makes good tests go bad?
Wherein we discuss real world
test practices for making your
testing bad, and conversely,
what you can do to mitigate your
self destructive tendencies.

10
By any means necessary
Wherein locators are discussed,
including the use of Custom locators
because you deserve to be in control

11
Basic WebDriver
Commands


Driver level



WebElement level

12
WebDriverWait exposed
Wherein we discuss Fluently the
intricacies of waiting; an oft
forgotten art of Explicitly taking
control of your waiting time rather
than Implicitly assuming the
passage of time

13
JavaScript
Wherein we discuss the nuances of
working with the ubiquitous;
synchronously, asynchronously
and on taking as well as giving.

14
“I have to handle an alert in
my application but
WebDriver doesn't let me...”
Wherein we discuss the handling of alerts
and learn what an alert is, what an alert is
not, and what to do about it.
15
Refactoring and Abstracting
Wherein we discuss the modeling of
test automation in the real world and
consider; should we refactor to
models, or build from models, and
how much of a good thing is too
much before a good thing goes bad
and becomes a bad thing from
whence it was once good.
16
Questions and Challenges


Answered & Discussed



Offered

17
Alan Richardson


www.eviltester.com



www.compendiumdev.co.uk



www.seleniumsimplified.com



@eviltester

18
Simon Stewart


blog.rocketpoweredjetpants.com



@shs96c

19
WebDriver Tutorial
Reference Slides
For More like this visit:


Http://seleniumsimplified.com



http://unow.be/at/webdriverapi

The following slides are excerpts from the Online course
20
In Selenium 2.0 The Driver
is King


Selenium 1.0




The Server is King

Selenium 2.0


The Driver is King
WebDriver is
the most important
Object in the hierarchy.

21
First Test
@Test
public void driverIsTheKing(){
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.compendiumdev.co.uk/selenium");
assertTrue(driver.getTitle().startsWith(
"Selenium Simplified"));
}

22
First Test Explained
Junit test

A headless
Implementation
of a Driver

Core Interface
to understand

@Test
public void driverIsTheKing(){
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.compendiumdev.co.uk/selenium");
assertTrue(driver.getTitle().startsWith(
"Selenium Simplified"));

Most basic
navigation
command

}
Return page
title as a string

A JUnit assert
23
Real Browser Explored
Implementations exist
for Firefox, Chrome, IE
Opera, etc.

@Test
public void firefoxIsSupportedByWebDriver(){
WebDriver driver = new FirefoxDriver();

driver.get("http://www.compendiumdev.co.uk/selenium");
assertEquals(true,
driver.getTitle().
startsWith("Selenium Simplified"));
driver.close();
}

close() or quit()
physical
browsers
24
What are the basics that
we need to know so that
we can automate the web?

25
Basic Knowledge Chunked
Open a browser

Navigate to page

Navigate

Read the page title

Read the url

Get text from the page

Interrogate

Click on links

Fill in forms

Click on buttons

Manipulate







& Synchronize
26
Assertions


assertTrue(“description”, expected, actual)






AssertFalse(...)

assertEquals(“description”, expected,
actual)
Used to check results

27
Junit Example
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class JUnitExampleTest {
@Test
public void aBasicJUnitTest(){
assertEquals("2+2=4", 4, 2+2);
}

}

Actual Value
Expected Value
Message

28
More JUnit




Avoid repeating code in your @Test
methods
Before and after each @Test





@Before
@After

Once per class


@BeforeClass



@AfterClass



Declare methods as static
29
Navigation Annotated


driver


.get(<url>)



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

.navigate






'to' a URL String
'to' a java.net.URL Object

.to(<url>)
.to(URL)
.back()
.forward()
.refresh()

'back' through browser history
'forward' through browser history
'refresh' the current browser page

30
Navigation Example Test
private static WebDriver driver;
@BeforeClass
public static void createDriver(){
}

driver = new FirefoxDriver();

driver needs to be static
because of @BeforeClass
and @AfterClass
Execute this method
once per class. Before
any of the @Test methods
have run.

@Test
public void navigateWithNavigateTo(){
driver.navigate().to(
"http://www.compendiumdev.co.uk/selenium/search.php"
);
assertTrue(driver.getTitle().
startsWith("Selenium Simplified Search
Engine"));
}
@AfterClass
public static void quitDriver(){
}

driver.quit();

31

Execute this method
once per class. After all
@Test methods have run.
DriverInterrogateTest
@Test
public void driverLevelPageInterrogateMethods(){
WebDriver driver;
final String theTestPageURL =
"http://www.compendiumdev.co.uk/selenium/basic_web_page.html";
driver = new FirefoxDriver();
driver.navigate().to(theTestPageURL);
assertEquals(driver.getTitle(), "Basic Web Page Title");
assertEquals(driver.getCurrentUrl(), theTestPageURL);
String pageSource = driver.getPageSource();
assertTrue(pageSource.contains("A paragraph of text"));
driver.close();
}
32
Be Careful with getPageSource
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">
<html>
<head>
<title>Basic Web Page Title</title>
</head>
<body>
<p id="para1" class="main">A paragraph of text</p>
<p id="para2" class="sub">Another paragraph of
text</p>
</body>
</html>

Line separation

Additional
attributes

Attribute
Ordering

File on
server

Firefox
Driver
Differences

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>Basic Web Page Title</title>
String
</head>
returned
<body>
<p class="main" id="para1">A paragraph of text</p>
by
<p class="sub" id="para2">Another paragraph of text</p>

method

</body></html>

33
Dom Element Interrogation
Approach


Find the Dom Element (WebElement)





.findElement
.findElements

Use the WebElement Object methods:


.getText()



.isSelected()



.getAttribute()



.isDisplayed()



.getTagName()



.getSize()



.isEnabled()



.getLocation()



34

.
getCssValue()
Driver .findElement(By)
driver.findElement(By.id("para1"))



By.id



By.xpath



By.cssSelector



By.className



By.linkText



By.name



By.tagName



By.partialLinkText 35

We find an element
By using a locator
strategy.
e.g. by using the id,
by evaluating an
xpath expression, by
executing a css
selector, etc.
ExampleFirstFindByTest
public class ExampleFirstFindByTest {
static WebDriver driver;
@BeforeClass
public static void createDriverAndVisitTestPage(){
driver = new FirefoxDriver();
driver.get("http://www.compendiumdev.co.uk/" +
"selenium/find_by_playground.php");
}
@Test
public void findByID(){
WebElement cParagraph = driver.findElement(By.id("p3"));
assertEquals("This is c paragraph text",
cParagraph.getText());
}

}

@AfterClass
public static void closeBrowser(){
driver.quit();
}
36
.findElements





.findElement only returns 1 WebElement
If the By could return more elements then
.findElement retursn the first in the list
.findElements returns the full list of
matching WebElements


e.g. driver.findElements(By.className(“normal”));

37
Useful Tools For CSS and
XPath


Firefox




Install FireBug and FirePath plugins

Chrome


Developer tools are supposed to allow search
using xpath or css (sometimes this breaks
between releases)

38
WebElement Manipulation


.click()



.clear()




.sendKeys(String) actually (CharSequence)






Clear a field
Sends the appropriate events to a
WebElement keyup, keydown, etc.
Helper Keys class
(org.openqa.selenium.Keys)

.submit()


Submit a form

39
Introducing WebDriverWait






WebDriver has a helper class
WebDriverWait which can help us
synchronise our tests
Used in conjunction with another helper
class ExpectedConditions
We can write simple synchronisation
statements

new WebDriverWait(driver,10).
until(
ExpectedConditions.titleIs("HTML Form Elements"));
40
Manipulation Example Test
public class ManipulateExampleTest {
static WebDriver driver;
@BeforeClass
public static void createDriverAndVisitTestPage(){
driver = new FirefoxDriver();
driver = driver.get( "http://www.compendiumdev.co.uk" +
"/selenium/basic_html_form.html");
}
@Test
public void simpleInteraction(){
WebElement checkBox1 = driver.findElement(
By.cssSelector("input[value='cb1']"));
assertFalse("Starts not selected",
checkBox1.isSelected());
checkBox1.click();

}

}

assertTrue("Click selects",
checkBox1.isSelected());

@AfterClass
public static void closeBrowser(){
driver.quit();
}

41
Manipulation Summary




Filename fields
use .sendKeys
Checkbox and radio
items






.isSelected, .click



Can clear text or
text area

42

Cannot clear a
checkbox,
multiselect, drop
down, or
radiobutton
Simple
manipulation has a
very simple set of
methods
More on SendKeys


Keys.chord to send Key Sequences



Shift, CTRL etc start a modifier sequence



Keys.NULL ends a modifier sequence

commentTextArea.sendKeys(
Keys.chord(Keys.SHIFT, "bob", Keys.NULL, " Dobbs"));
assertEquals("BOB Dobbs", commentTextArea.getText())

43
User Interactions Example
Actions actions = new Actions(driver);
actions.click(multiSelectOptions.get(0)).
click(multiSelectOptions.get(1)).
click(multiSelectOptions.get(2)).perform();
clickSubmitButton();





Previously all 3 were selected, which
didn't mirror real life
Here, only 1 is selected, which does
mirror real life
44
Use User Interactions
Carefully


Can vary between machines & browsers



If plain WebDriver works then use it





Use User Interactions for 'complex'
situations
If you are having problems then check the
forums, you might not be the only one

45
Alerts


Handle Alerts with


driver.switchTo().alert()







The hierarchy is
'kinda' obvious
When you think
About it.
Keep searching.
Learn the API.

.getText()
.dismiss()
.accept()
.sendKeys(String)

.alert() returns an Alert object

46
Frames Example
@Test
public void switchToFrameExample(){
WebDriver driver =
Driver.get("http://www.compendiumdev.co.uk/selenium/frames");
assertEquals("Frameset Example Title (Example 6)",
driver.getTitle());
Switch to the
If I don't switch
menu frame.
then I'll get a
NoSuchElementException
driver.switchTo().frame("menu");
driver.findElement(
By.cssSelector("a[href='frames_example_1.html']")).click();
String titleForExample1 = "Frameset Example Title (Example 1)";
new WebDriverWait(driver,Driver.DEFAULT_TIMEOUT_SECONDS).
until(ExpectedConditions.titleIs(titleForExample1));
}

assertEquals(titleForExample1,driver.getTitle());
Had to Synchronise
on the page change.

47
Windows


Each Browser window has a unique handle








e.g {b3e5c07c-fac7-492f-a86d-d2fa57608185}

driver.getWindowHandle() returns handle
for current window
driver.getWindowHandles() returns a
Set<String> of all window handles
driver.switchTo.window(String handle)
switches control to the chosen window
48
@Test
public void switchToNewWindow(){

Window Example

WebDriver driver = Driver.get(
"http://www.compendiumdev.co.uk/selenium/frames");
assertEquals("Expected only 1 current window", 1,
driver.getWindowHandles().size());

We start with one
window open

String framesWindowHandle = driver.getWindowHandle();
driver.switchTo().frame("content");
driver.findElement(By.cssSelector(
"a[href='http://www.seleniumsimplified.com']")).click();
assertEquals("Expected a New Window opened", 2,
driver.getWindowHandles().size());
Set<String> myWindows = driver.getWindowHandles();
String newWindowHandle="";
for(String aHandle : myWindows){
if(!framesWindowHandle.contentEquals(aHandle)){
newWindowHandle = aHandle; break;
}
}
driver.switchTo().window(newWindowHandle);
assertTrue("Expected Selenium Simplified site",
driver.getTitle().contains("Selenium Simplified"));
}

49

Remember the current
window handle
Clicking on this
Link opens a new
window
Find the new
window handle
Switch to the
new window

Driver commands now
act on new window
Manage Window Example
@Test
public void manageWindow(){

Position moves
The window around

WebDriver driver = Driver.get(
"http://www.compendiumdev.co.uk/selenium/frames");
driver.manage().window().setPosition(new Point(10,20));
Point pos = driver.manage().window().getPosition();
assertEquals(10, pos.getX());
assertEquals(20, pos.getY());

Position uses
X & Y co-ords

Position uses a
Point object

driver.manage().window().setSize(new Dimension(350,400));
Dimension winSizes = driver.manage().window().getSize();

}

assertEquals(350, winSizes.getWidth());
assertEquals(400, winSizes.getHeight());
Size uses Dimensions i.e width and height
50

Size...
Resizes
the
browser
window
Custom ExpectedCondition
new WebDriverWait(driver,10).until(
new SelectContainsText(By.id("combo2"),"Java")
);


Why?








ExpectedConditions doesn't have what you
need
You want to make your tests read well for your
usage scenario
You want to pass additional values to the apply
method

... create a Custom ExpectedCondition
51
Custom ExpectedCondition Example
I made it private because
It is local to my test, normally
this would be public

You can return either
Boolean or WebElement.
I chose Boolean for this.

private class SelectContainsText implements ExpectedCondition<Boolean> {

Pass in whatever you need
in the constructor

private String textToFind;
private By findBy;

public SelectContainsText(final By comboFindBy, final String textToFind) {
this.findBy = comboFindBy;
this.textToFind = textToFind;
Override apply, this is
}

called by WebDriverWait

@Override
public Boolean apply(WebDriver webDriver) {
WebElement combo = webDriver.findElement(this.findBy);
List<WebElement> options = combo.findElements(By.tagName("option"));
for(WebElement anOption : options){
if(anOption.getText().equals(this.textToFind))
return true;
}

}

}

Implement your checking code
using the passed in WebDriver

return false;

52
Use WebDriverWait
Fluently


Additional methods



.ignoring



.withTimeout



.withMessage





.pollingEvery

.etc

Allow us to customise WebDriverWait
fluently
53
Use WebDriverWait
Fluently
Override polling time

new WebDriverWait(driver, 1).
pollingEvery(100, TimeUnit.MILLISECONDS).
ignoring(IllegalStateException.class).

Ignore Exceptions
Override timeout

withTimeout(5, TimeUnit.SECONDS).
withMessage("will wait 5 seconds").

);

Include text in Timeout Message

until(
new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver webDriver) {
throw new IllegalStateException();
}
}

54
ExpectedCondition &
Function


An ExpectedCondition implements Function
applying to WebDriver objects



Function<WebDriver, T>
The apply acts on a WebDriver but it can
return any Object e.g. Boolean, WebElement

55
FluentWait




WebDriverWait extends FluentWait so
everything you have seen is really
FluentWait
Main difference between FluentWait and
WebDriver Wait:


FluentWait can apply to anything


e.g. WebElement, not just WebDriver

56
Function & Predicate


FluentWait can use Predicate or Function,
on any object


Function<F, T>



Predicate<T>

57
FluentWait Example

Declare that a
WebElement will be
passed to the wait

countdown = driver.findElement(

y.id("javascript_countdown_time"));

Pass in WebElement

new FluentWait<WebElement>(countdown).

Configure wait fluently

withTimeout(10, TimeUnit.SECONDS).
pollingEvery(100,TimeUnit.MILLISECONDS).
until(new Function<WebElement, Boolean>() {

}
);

@Override
public Boolean apply(WebElement element) {
return element.getText().endsWith("04");
}
Declare returning
a Boolean
58
Implicit or Explicit?


Implicit can make initial tests faster to write




It can be harder to add synchronisation
later




you don't worry about synchronisation when
writing tests

You have to identify a source of intermittency

If you start with implicit then you can
expose synchronisation problems by
gradually reducing the implicit wait time
59
Implicit or Explicit?


Implicit can make initial tests faster to write




It can be harder to add synchronisation
later




you don't worry about synchronisation when
writing tests

You have to identify a source of intermittency

If you start with implicit then you can
expose synchronisation problems by
gradually reducing the implicit wait time
60
Cookies


Inspect


driver.manage





.getCookies()
.getCookieNamed(“name”)

Interact


driver.manage





.addCookie(Cookie)
.deleteAllCookies
.deleteCookie(Cookie)
.deleteCookieNamed(“name”)
61
Cookies Example
@Test
public void visitSearchPageAndCheckNoLastSearchCookie(){
WebDriver driver;
driver = Driver.get("http://compendiumdev.co.uk/selenium/search.php");

Delete all cookies
for current domain

driver.manage().deleteAllCookies();
driver.navigate().refresh();

Refresh page to get
an initial set of
cookies

Find a named cookie
Return null if not found
Cookie aCookie =
driver.manage().getCookieNamed("SeleniumSimplifiedLastSearch");
}

assertEquals("Should be no last search cookie", null, aCookie);

62
Javascript Execution


Cast WebDriver to JavascriptExecutor





.executeScript(script, args...)
.executeAsyncScript(script, args...)

Arguments are accessed using




arguments[index] e.g. "document.title=arguments[0]"

Return values are converted to Java types


Html Element = WebElement, decimal =
Double, non-decimal = Long, boolean =
Boolean, array = List<Object>, else String or
63
null
(JavascriptExecutor)
Example
@Test
public void callAJavaScriptFunctionOnThePage(){

Test page is at
compendiumdev.co.uk/
selenium/canvas_basic.html

WebDriver driver = Driver.get(
"http://www.compendiumdev.co.uk/selenium/canvas_basic.html");
JavascriptExecutor js =(JavascriptExecutor)driver;
int actionsCount = driver.findElements(
By.cssSelector("#commandlist li")).size();
assertEquals("By default app has 2 actions listed",
2, actionsCount);
js.executeScript("draw(1, 150,150,40, '#FF1C0A');");

}

actionsCount = driver.findElements(
By.cssSelector("#commandlist li")).size();
assertEquals("Calling draw should add an action",
3, actionsCount);

64

Cast driver to
JavascriptExecutor
to access the
JavaScript methods

Execute the 'draw'
Function in the page
ChromeDriver


http://code.google.com/p/selenium/wiki/ChromeDriver



Download the driver server




Command line switches






set "webdriver.chrome.driver" to the location
http://peter.sh/experiments/chromiumcommand-line-switches/
Pass in as options

ChromeDriver.log is useful debugging tool
65
Remote Driver


When server is running on another machine



e.g. SauceLabs.com

DesiredCapabilities capabilities;

Remote driver
configured by
capabilities

capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("version", "5");
capabilities.setCapability("platform", Platform.XP);
try {

String sauceURL = System.getenv("SAUCELABS_URL");
aDriver = new RemoteWebDriver(
new URL(sauceURL),
capabilities);
Watch out for
UnsupportedCommandException
} catch (MalformedURLException e) {
during your tests
e.printStackTrace();
}
66
Try Different Browsers


Some tests will fail due to:


Driver issues




Aaargh, I knew
it was too easy!

Bugs in the drivers

Driver differences



different exceptions thrown,
new exceptions thrown



Incompatible driver/browser versions



Driver scope




Some functionality not implemented

Documentation differences


67

Look at log output or read source

… etc.
WebDriver Summary Sheet

WebDriver Interact
= new <driverClass>()

Inspect

.close()
.quit()

Finding elements

WebDriver
.getTitle()
.getCurrentUrl()

Navigate

.navigate

WebElement =
.findElement(BY)

.getPageSource()

WebDriver
.get(“URL”)

WebDriver

List<WebElement> =
.findElements(BY)

WebElement

Interact
WebElement

SwitchTo.

.click()

.alert()

.submit()
.clear()

By
.id(“an_id”)

.getText()

.sendKeys(String)
.sendKeys(Keys.x)

.to(Url)

.getAttribute(“name”)

.to(“URL”)

.getTagName()

.xpath(“xpath”)

.back()

.isEnabled()

.cssSelector(“css”)

support.ui.Select

.forward()

.isSelected()

.className(“class”)

.isDisplayed()

.linkText(“text”)

.getSize()

.name(“name”

.getLocation()

.tagName(“a_tag”)

.getCssValue()

.partialLinkText(“t”);

.accept()
.dismiss()

.<methods>()

.refresh()

.getText()

Synchronise

.sendKeys(String)
.frame(...)

Cookies
WebDriver
.manage()
.deleteAllCookies()

Support

.addCookie(Cookie)

WebDriverWait

ByChaining(By, By)

.deleteCookie(Cookie)

(driver, timeout in Seconds)
.until(ExpectedCondition)

ByIdOrName(“idName”)

.deleteCookieNamed(String)

ExpectedConditions
.titleIs(String)
… a lot of helper methods

Cookies

Actions

(JavascriptExecutor)

WebDriver

.keyUp() etc.

.executeScript

.perform()

.manage()
.getCookieNamed(String)
.getCookies()

68
End Points




You will encounter problems we haven't
covered here
You will need to download and read the
Selenium 2.0 source code as you test

69
Basic Practice Pages


http://compendiumdev.co.uk/selenium/




calculate.php



basic_ajax.html



find_by_playground.php



basic_web_page.html



refresh.php



basic_html_form.html



search.php





alert.html

ajaxselect.php

Source available at
https://bitbucket.org/ajrichardson/seleniumtestpages

70
Advanced Practice Pages


http://compendiumdev.co.uk/selenium/




Showcase/Showcase.html

Source available at
https://bitbucket.org/ajrichardson/simplegwtshowcaseclone

71
WebDriver Tutorial
Reference Slides
For More like this visit:


Http://seleniumsimplified.com



Online Course: http://unow.be/at/webdriverapi

The reference slides are excerpts from the above online course
72

More Related Content

What's hot

Automating Strategically or Tactically when Testing
Automating Strategically or Tactically when TestingAutomating Strategically or Tactically when Testing
Automating Strategically or Tactically when TestingAlan Richardson
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Hazem Saleh
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Joe Ferguson
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in YiiIlPeach
 
From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.David Aguilera
 
High Performance JavaScript 2011
High Performance JavaScript 2011High Performance JavaScript 2011
High Performance JavaScript 2011Nicholas Zakas
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answerskavinilavuG
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web ApplicationsSeth McLaughlin
 
Selenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web ApplicationsSelenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web Applicationsqooxdoo
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: DemystifiedSeth McLaughlin
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Cogapp
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to codeAlan Richardson
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Automate testing with behat, selenium, phantom js and nightwatch.js (5)Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Automate testing with behat, selenium, phantom js and nightwatch.js (5)Faichi Solutions
 
Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteMediacurrent
 

What's hot (20)

Automating Strategically or Tactically when Testing
Automating Strategically or Tactically when TestingAutomating Strategically or Tactically when Testing
Automating Strategically or Tactically when Testing
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in Yii
 
From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.
 
High Performance JavaScript 2011
High Performance JavaScript 2011High Performance JavaScript 2011
High Performance JavaScript 2011
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 
Selenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web ApplicationsSelenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web Applications
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to code
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Codeception
CodeceptionCodeception
Codeception
 
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Automate testing with behat, selenium, phantom js and nightwatch.js (5)Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
 
Integration Testing in Python
Integration Testing in PythonIntegration Testing in Python
Integration Testing in Python
 
Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal Site
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
 

Similar to Selenium Clinic Eurostar 2012 WebDriver Tutorial

Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Innoplexia DevTools to Crawl Webpages
Innoplexia DevTools to Crawl WebpagesInnoplexia DevTools to Crawl Webpages
Innoplexia DevTools to Crawl Webpagesd0x
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in Sandeep Tol
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaAgile Testing Alliance
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopMark Rackley
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaSandeep Tol
 
Get Started With Selenium 3 and Selenium 3 Grid
Get Started With Selenium 3 and Selenium 3 GridGet Started With Selenium 3 and Selenium 3 Grid
Get Started With Selenium 3 and Selenium 3 GridDaniel Herken
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionAmr E. Mohamed
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For ManagersAgileThought
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterBoni García
 

Similar to Selenium Clinic Eurostar 2012 WebDriver Tutorial (20)

Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Innoplexia DevTools to Crawl Webpages
Innoplexia DevTools to Crawl WebpagesInnoplexia DevTools to Crawl Webpages
Innoplexia DevTools to Crawl Webpages
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in Java
 
Get Started With Selenium 3 and Selenium 3 Grid
Get Started With Selenium 3 and Selenium 3 GridGet Started With Selenium 3 and Selenium 3 Grid
Get Started With Selenium 3 and Selenium 3 Grid
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Knolx session
Knolx sessionKnolx session
Knolx session
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For Managers
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 

More from Alan Richardson

Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021Alan Richardson
 
Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Alan Richardson
 
The Future of Testing Webinar
The Future of Testing WebinarThe Future of Testing Webinar
The Future of Testing WebinarAlan Richardson
 
Secrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesSecrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesAlan Richardson
 
Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Alan Richardson
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonAlan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsAlan Richardson
 
Technology Based Testing
Technology Based TestingTechnology Based Testing
Technology Based TestingAlan Richardson
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAlan Richardson
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST APIAlan Richardson
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameTechnical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameAlan Richardson
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzAlan Richardson
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With AgilityAlan Richardson
 
Your Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyYour Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyAlan Richardson
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.Alan Richardson
 
What is Agile Testing? A MindMap
What is Agile Testing? A MindMapWhat is Agile Testing? A MindMap
What is Agile Testing? A MindMapAlan Richardson
 
Evil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingEvil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingAlan Richardson
 
The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017Alan Richardson
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?Alan Richardson
 

More from Alan Richardson (20)

Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021Add More Security To Your Testing and Automating - Saucecon 2021
Add More Security To Your Testing and Automating - Saucecon 2021
 
Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009
 
The Future of Testing Webinar
The Future of Testing WebinarThe Future of Testing Webinar
The Future of Testing Webinar
 
Secrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slidesSecrets and Mysteries of Automated Execution Keynote slides
Secrets and Mysteries of Automated Execution Keynote slides
 
Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604Automating Pragmatically - Testival 20190604
Automating Pragmatically - Testival 20190604
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStrings
 
Technology Based Testing
Technology Based TestingTechnology Based Testing
Technology Based Testing
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil Tester
 
Shift left-testing
Shift left-testingShift left-testing
Shift left-testing
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST API
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" GameTechnical and Testing Challenges: Using the "Protect The Square" Game
Technical and Testing Challenges: Using the "Protect The Square" Game
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzz
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With Agility
 
Your Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be FlakyYour Automated Execution Does Not Have to be Flaky
Your Automated Execution Does Not Have to be Flaky
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.
 
What is Agile Testing? A MindMap
What is Agile Testing? A MindMapWhat is Agile Testing? A MindMap
What is Agile Testing? A MindMap
 
Evil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingEvil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile Testing
 
The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Selenium Clinic Eurostar 2012 WebDriver Tutorial

  • 1. Selenium Clinic Alan Richardson (@eviltester), Simon Stewart (@shs96c) www.eurostarconferences.com @esconfs #esconfs
  • 2. What Is This? These slides were used in the “Best Tutorial” Award winning tutorial from Eurostar 2012 hosted by Simon Stewart and Alan Richardson Most of these slides form part of the slide deck for Alan Richardson's Online Course http://unow.be/at/webdriverapi So if you like what you read here – check out the full 18+ hour tutorial with 200+ slides
  • 3. Selenium Conference Do you with there was a conference dedicated to all things Selenium? Well there is: http://www.seleniumconf.org/ It may be happening soon. It may be near you. Check the site for more details.
  • 4. Source Code The source code developed during the tutorial and in preparation for the tutorial can be found on github: https://github.com/shs96c/selenium_clinic
  • 6. Clinic ('klinik) 1. A tutorial, often associated with a conference that is devoted to the discussion of a single tool 2. A group session, often led by bearded gentlefolk, which offers hints and tips, points out oft neglected practices, and may offer practical hands on challenges 3. A place where such instruction occurs
  • 7. A Short History of Selenium “All Selenium trainers, are mandated* to provide a short history of Selenium where they describe Selenium (including WebDriver & Selenium-RC & grid etc.), they must also provide a brief history.” * it is a tradition or a law or an old charter or something Selenium-RC WebDriver 7
  • 8. Intro & Capabilities  Hello from Alan & Simon  Current Group Capabilities
  • 10. What makes good tests go bad? Wherein we discuss real world test practices for making your testing bad, and conversely, what you can do to mitigate your self destructive tendencies. 10
  • 11. By any means necessary Wherein locators are discussed, including the use of Custom locators because you deserve to be in control 11
  • 13. WebDriverWait exposed Wherein we discuss Fluently the intricacies of waiting; an oft forgotten art of Explicitly taking control of your waiting time rather than Implicitly assuming the passage of time 13
  • 14. JavaScript Wherein we discuss the nuances of working with the ubiquitous; synchronously, asynchronously and on taking as well as giving. 14
  • 15. “I have to handle an alert in my application but WebDriver doesn't let me...” Wherein we discuss the handling of alerts and learn what an alert is, what an alert is not, and what to do about it. 15
  • 16. Refactoring and Abstracting Wherein we discuss the modeling of test automation in the real world and consider; should we refactor to models, or build from models, and how much of a good thing is too much before a good thing goes bad and becomes a bad thing from whence it was once good. 16
  • 17. Questions and Challenges  Answered & Discussed  Offered 17
  • 20. WebDriver Tutorial Reference Slides For More like this visit:  Http://seleniumsimplified.com  http://unow.be/at/webdriverapi The following slides are excerpts from the Online course 20
  • 21. In Selenium 2.0 The Driver is King  Selenium 1.0   The Server is King Selenium 2.0  The Driver is King WebDriver is the most important Object in the hierarchy. 21
  • 22. First Test @Test public void driverIsTheKing(){ WebDriver driver = new HtmlUnitDriver(); driver.get("http://www.compendiumdev.co.uk/selenium"); assertTrue(driver.getTitle().startsWith( "Selenium Simplified")); } 22
  • 23. First Test Explained Junit test A headless Implementation of a Driver Core Interface to understand @Test public void driverIsTheKing(){ WebDriver driver = new HtmlUnitDriver(); driver.get("http://www.compendiumdev.co.uk/selenium"); assertTrue(driver.getTitle().startsWith( "Selenium Simplified")); Most basic navigation command } Return page title as a string A JUnit assert 23
  • 24. Real Browser Explored Implementations exist for Firefox, Chrome, IE Opera, etc. @Test public void firefoxIsSupportedByWebDriver(){ WebDriver driver = new FirefoxDriver(); driver.get("http://www.compendiumdev.co.uk/selenium"); assertEquals(true, driver.getTitle(). startsWith("Selenium Simplified")); driver.close(); } close() or quit() physical browsers 24
  • 25. What are the basics that we need to know so that we can automate the web? 25
  • 26. Basic Knowledge Chunked Open a browser  Navigate to page Navigate Read the page title  Read the url  Get text from the page Interrogate Click on links  Fill in forms  Click on buttons Manipulate    & Synchronize 26
  • 28. Junit Example import org.junit.Test; import static junit.framework.Assert.assertEquals; public class JUnitExampleTest { @Test public void aBasicJUnitTest(){ assertEquals("2+2=4", 4, 2+2); } } Actual Value Expected Value Message 28
  • 29. More JUnit   Avoid repeating code in your @Test methods Before and after each @Test    @Before @After Once per class  @BeforeClass  @AfterClass  Declare methods as static 29
  • 30. Navigation Annotated  driver  .get(<url>)  driver.get(“http://aURL.com”); .navigate      'to' a URL String 'to' a java.net.URL Object .to(<url>) .to(URL) .back() .forward() .refresh() 'back' through browser history 'forward' through browser history 'refresh' the current browser page 30
  • 31. Navigation Example Test private static WebDriver driver; @BeforeClass public static void createDriver(){ } driver = new FirefoxDriver(); driver needs to be static because of @BeforeClass and @AfterClass Execute this method once per class. Before any of the @Test methods have run. @Test public void navigateWithNavigateTo(){ driver.navigate().to( "http://www.compendiumdev.co.uk/selenium/search.php" ); assertTrue(driver.getTitle(). startsWith("Selenium Simplified Search Engine")); } @AfterClass public static void quitDriver(){ } driver.quit(); 31 Execute this method once per class. After all @Test methods have run.
  • 32. DriverInterrogateTest @Test public void driverLevelPageInterrogateMethods(){ WebDriver driver; final String theTestPageURL = "http://www.compendiumdev.co.uk/selenium/basic_web_page.html"; driver = new FirefoxDriver(); driver.navigate().to(theTestPageURL); assertEquals(driver.getTitle(), "Basic Web Page Title"); assertEquals(driver.getCurrentUrl(), theTestPageURL); String pageSource = driver.getPageSource(); assertTrue(pageSource.contains("A paragraph of text")); driver.close(); } 32
  • 33. Be Careful with getPageSource <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd"> <html> <head> <title>Basic Web Page Title</title> </head> <body> <p id="para1" class="main">A paragraph of text</p> <p id="para2" class="sub">Another paragraph of text</p> </body> </html> Line separation Additional attributes Attribute Ordering File on server Firefox Driver Differences <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Basic Web Page Title</title> String </head> returned <body> <p class="main" id="para1">A paragraph of text</p> by <p class="sub" id="para2">Another paragraph of text</p> method </body></html> 33
  • 34. Dom Element Interrogation Approach  Find the Dom Element (WebElement)    .findElement .findElements Use the WebElement Object methods:  .getText()  .isSelected()  .getAttribute()  .isDisplayed()  .getTagName()  .getSize()  .isEnabled()  .getLocation()  34 . getCssValue()
  • 35. Driver .findElement(By) driver.findElement(By.id("para1"))  By.id  By.xpath  By.cssSelector  By.className  By.linkText  By.name  By.tagName  By.partialLinkText 35 We find an element By using a locator strategy. e.g. by using the id, by evaluating an xpath expression, by executing a css selector, etc.
  • 36. ExampleFirstFindByTest public class ExampleFirstFindByTest { static WebDriver driver; @BeforeClass public static void createDriverAndVisitTestPage(){ driver = new FirefoxDriver(); driver.get("http://www.compendiumdev.co.uk/" + "selenium/find_by_playground.php"); } @Test public void findByID(){ WebElement cParagraph = driver.findElement(By.id("p3")); assertEquals("This is c paragraph text", cParagraph.getText()); } } @AfterClass public static void closeBrowser(){ driver.quit(); } 36
  • 37. .findElements    .findElement only returns 1 WebElement If the By could return more elements then .findElement retursn the first in the list .findElements returns the full list of matching WebElements  e.g. driver.findElements(By.className(“normal”)); 37
  • 38. Useful Tools For CSS and XPath  Firefox   Install FireBug and FirePath plugins Chrome  Developer tools are supposed to allow search using xpath or css (sometimes this breaks between releases) 38
  • 39. WebElement Manipulation  .click()  .clear()   .sendKeys(String) actually (CharSequence)    Clear a field Sends the appropriate events to a WebElement keyup, keydown, etc. Helper Keys class (org.openqa.selenium.Keys) .submit()  Submit a form 39
  • 40. Introducing WebDriverWait    WebDriver has a helper class WebDriverWait which can help us synchronise our tests Used in conjunction with another helper class ExpectedConditions We can write simple synchronisation statements new WebDriverWait(driver,10). until( ExpectedConditions.titleIs("HTML Form Elements")); 40
  • 41. Manipulation Example Test public class ManipulateExampleTest { static WebDriver driver; @BeforeClass public static void createDriverAndVisitTestPage(){ driver = new FirefoxDriver(); driver = driver.get( "http://www.compendiumdev.co.uk" + "/selenium/basic_html_form.html"); } @Test public void simpleInteraction(){ WebElement checkBox1 = driver.findElement( By.cssSelector("input[value='cb1']")); assertFalse("Starts not selected", checkBox1.isSelected()); checkBox1.click(); } } assertTrue("Click selects", checkBox1.isSelected()); @AfterClass public static void closeBrowser(){ driver.quit(); } 41
  • 42. Manipulation Summary   Filename fields use .sendKeys Checkbox and radio items    .isSelected, .click  Can clear text or text area 42 Cannot clear a checkbox, multiselect, drop down, or radiobutton Simple manipulation has a very simple set of methods
  • 43. More on SendKeys  Keys.chord to send Key Sequences  Shift, CTRL etc start a modifier sequence  Keys.NULL ends a modifier sequence commentTextArea.sendKeys( Keys.chord(Keys.SHIFT, "bob", Keys.NULL, " Dobbs")); assertEquals("BOB Dobbs", commentTextArea.getText()) 43
  • 44. User Interactions Example Actions actions = new Actions(driver); actions.click(multiSelectOptions.get(0)). click(multiSelectOptions.get(1)). click(multiSelectOptions.get(2)).perform(); clickSubmitButton();   Previously all 3 were selected, which didn't mirror real life Here, only 1 is selected, which does mirror real life 44
  • 45. Use User Interactions Carefully  Can vary between machines & browsers  If plain WebDriver works then use it   Use User Interactions for 'complex' situations If you are having problems then check the forums, you might not be the only one 45
  • 46. Alerts  Handle Alerts with  driver.switchTo().alert()      The hierarchy is 'kinda' obvious When you think About it. Keep searching. Learn the API. .getText() .dismiss() .accept() .sendKeys(String) .alert() returns an Alert object 46
  • 47. Frames Example @Test public void switchToFrameExample(){ WebDriver driver = Driver.get("http://www.compendiumdev.co.uk/selenium/frames"); assertEquals("Frameset Example Title (Example 6)", driver.getTitle()); Switch to the If I don't switch menu frame. then I'll get a NoSuchElementException driver.switchTo().frame("menu"); driver.findElement( By.cssSelector("a[href='frames_example_1.html']")).click(); String titleForExample1 = "Frameset Example Title (Example 1)"; new WebDriverWait(driver,Driver.DEFAULT_TIMEOUT_SECONDS). until(ExpectedConditions.titleIs(titleForExample1)); } assertEquals(titleForExample1,driver.getTitle()); Had to Synchronise on the page change. 47
  • 48. Windows  Each Browser window has a unique handle     e.g {b3e5c07c-fac7-492f-a86d-d2fa57608185} driver.getWindowHandle() returns handle for current window driver.getWindowHandles() returns a Set<String> of all window handles driver.switchTo.window(String handle) switches control to the chosen window 48
  • 49. @Test public void switchToNewWindow(){ Window Example WebDriver driver = Driver.get( "http://www.compendiumdev.co.uk/selenium/frames"); assertEquals("Expected only 1 current window", 1, driver.getWindowHandles().size()); We start with one window open String framesWindowHandle = driver.getWindowHandle(); driver.switchTo().frame("content"); driver.findElement(By.cssSelector( "a[href='http://www.seleniumsimplified.com']")).click(); assertEquals("Expected a New Window opened", 2, driver.getWindowHandles().size()); Set<String> myWindows = driver.getWindowHandles(); String newWindowHandle=""; for(String aHandle : myWindows){ if(!framesWindowHandle.contentEquals(aHandle)){ newWindowHandle = aHandle; break; } } driver.switchTo().window(newWindowHandle); assertTrue("Expected Selenium Simplified site", driver.getTitle().contains("Selenium Simplified")); } 49 Remember the current window handle Clicking on this Link opens a new window Find the new window handle Switch to the new window Driver commands now act on new window
  • 50. Manage Window Example @Test public void manageWindow(){ Position moves The window around WebDriver driver = Driver.get( "http://www.compendiumdev.co.uk/selenium/frames"); driver.manage().window().setPosition(new Point(10,20)); Point pos = driver.manage().window().getPosition(); assertEquals(10, pos.getX()); assertEquals(20, pos.getY()); Position uses X & Y co-ords Position uses a Point object driver.manage().window().setSize(new Dimension(350,400)); Dimension winSizes = driver.manage().window().getSize(); } assertEquals(350, winSizes.getWidth()); assertEquals(400, winSizes.getHeight()); Size uses Dimensions i.e width and height 50 Size... Resizes the browser window
  • 51. Custom ExpectedCondition new WebDriverWait(driver,10).until( new SelectContainsText(By.id("combo2"),"Java") );  Why?     ExpectedConditions doesn't have what you need You want to make your tests read well for your usage scenario You want to pass additional values to the apply method ... create a Custom ExpectedCondition 51
  • 52. Custom ExpectedCondition Example I made it private because It is local to my test, normally this would be public You can return either Boolean or WebElement. I chose Boolean for this. private class SelectContainsText implements ExpectedCondition<Boolean> { Pass in whatever you need in the constructor private String textToFind; private By findBy; public SelectContainsText(final By comboFindBy, final String textToFind) { this.findBy = comboFindBy; this.textToFind = textToFind; Override apply, this is } called by WebDriverWait @Override public Boolean apply(WebDriver webDriver) { WebElement combo = webDriver.findElement(this.findBy); List<WebElement> options = combo.findElements(By.tagName("option")); for(WebElement anOption : options){ if(anOption.getText().equals(this.textToFind)) return true; } } } Implement your checking code using the passed in WebDriver return false; 52
  • 54. Use WebDriverWait Fluently Override polling time new WebDriverWait(driver, 1). pollingEvery(100, TimeUnit.MILLISECONDS). ignoring(IllegalStateException.class). Ignore Exceptions Override timeout withTimeout(5, TimeUnit.SECONDS). withMessage("will wait 5 seconds"). ); Include text in Timeout Message until( new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver webDriver) { throw new IllegalStateException(); } } 54
  • 55. ExpectedCondition & Function  An ExpectedCondition implements Function applying to WebDriver objects   Function<WebDriver, T> The apply acts on a WebDriver but it can return any Object e.g. Boolean, WebElement 55
  • 56. FluentWait   WebDriverWait extends FluentWait so everything you have seen is really FluentWait Main difference between FluentWait and WebDriver Wait:  FluentWait can apply to anything  e.g. WebElement, not just WebDriver 56
  • 57. Function & Predicate  FluentWait can use Predicate or Function, on any object  Function<F, T>  Predicate<T> 57
  • 58. FluentWait Example Declare that a WebElement will be passed to the wait countdown = driver.findElement( y.id("javascript_countdown_time")); Pass in WebElement new FluentWait<WebElement>(countdown). Configure wait fluently withTimeout(10, TimeUnit.SECONDS). pollingEvery(100,TimeUnit.MILLISECONDS). until(new Function<WebElement, Boolean>() { } ); @Override public Boolean apply(WebElement element) { return element.getText().endsWith("04"); } Declare returning a Boolean 58
  • 59. Implicit or Explicit?  Implicit can make initial tests faster to write   It can be harder to add synchronisation later   you don't worry about synchronisation when writing tests You have to identify a source of intermittency If you start with implicit then you can expose synchronisation problems by gradually reducing the implicit wait time 59
  • 60. Implicit or Explicit?  Implicit can make initial tests faster to write   It can be harder to add synchronisation later   you don't worry about synchronisation when writing tests You have to identify a source of intermittency If you start with implicit then you can expose synchronisation problems by gradually reducing the implicit wait time 60
  • 62. Cookies Example @Test public void visitSearchPageAndCheckNoLastSearchCookie(){ WebDriver driver; driver = Driver.get("http://compendiumdev.co.uk/selenium/search.php"); Delete all cookies for current domain driver.manage().deleteAllCookies(); driver.navigate().refresh(); Refresh page to get an initial set of cookies Find a named cookie Return null if not found Cookie aCookie = driver.manage().getCookieNamed("SeleniumSimplifiedLastSearch"); } assertEquals("Should be no last search cookie", null, aCookie); 62
  • 63. Javascript Execution  Cast WebDriver to JavascriptExecutor    .executeScript(script, args...) .executeAsyncScript(script, args...) Arguments are accessed using   arguments[index] e.g. "document.title=arguments[0]" Return values are converted to Java types  Html Element = WebElement, decimal = Double, non-decimal = Long, boolean = Boolean, array = List<Object>, else String or 63 null
  • 64. (JavascriptExecutor) Example @Test public void callAJavaScriptFunctionOnThePage(){ Test page is at compendiumdev.co.uk/ selenium/canvas_basic.html WebDriver driver = Driver.get( "http://www.compendiumdev.co.uk/selenium/canvas_basic.html"); JavascriptExecutor js =(JavascriptExecutor)driver; int actionsCount = driver.findElements( By.cssSelector("#commandlist li")).size(); assertEquals("By default app has 2 actions listed", 2, actionsCount); js.executeScript("draw(1, 150,150,40, '#FF1C0A');"); } actionsCount = driver.findElements( By.cssSelector("#commandlist li")).size(); assertEquals("Calling draw should add an action", 3, actionsCount); 64 Cast driver to JavascriptExecutor to access the JavaScript methods Execute the 'draw' Function in the page
  • 65. ChromeDriver  http://code.google.com/p/selenium/wiki/ChromeDriver  Download the driver server   Command line switches    set "webdriver.chrome.driver" to the location http://peter.sh/experiments/chromiumcommand-line-switches/ Pass in as options ChromeDriver.log is useful debugging tool 65
  • 66. Remote Driver  When server is running on another machine  e.g. SauceLabs.com DesiredCapabilities capabilities; Remote driver configured by capabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("version", "5"); capabilities.setCapability("platform", Platform.XP); try { String sauceURL = System.getenv("SAUCELABS_URL"); aDriver = new RemoteWebDriver( new URL(sauceURL), capabilities); Watch out for UnsupportedCommandException } catch (MalformedURLException e) { during your tests e.printStackTrace(); } 66
  • 67. Try Different Browsers  Some tests will fail due to:  Driver issues   Aaargh, I knew it was too easy! Bugs in the drivers Driver differences   different exceptions thrown, new exceptions thrown  Incompatible driver/browser versions  Driver scope   Some functionality not implemented Documentation differences  67 Look at log output or read source … etc.
  • 68. WebDriver Summary Sheet WebDriver Interact = new <driverClass>() Inspect .close() .quit() Finding elements WebDriver .getTitle() .getCurrentUrl() Navigate .navigate WebElement = .findElement(BY) .getPageSource() WebDriver .get(“URL”) WebDriver List<WebElement> = .findElements(BY) WebElement Interact WebElement SwitchTo. .click() .alert() .submit() .clear() By .id(“an_id”) .getText() .sendKeys(String) .sendKeys(Keys.x) .to(Url) .getAttribute(“name”) .to(“URL”) .getTagName() .xpath(“xpath”) .back() .isEnabled() .cssSelector(“css”) support.ui.Select .forward() .isSelected() .className(“class”) .isDisplayed() .linkText(“text”) .getSize() .name(“name” .getLocation() .tagName(“a_tag”) .getCssValue() .partialLinkText(“t”); .accept() .dismiss() .<methods>() .refresh() .getText() Synchronise .sendKeys(String) .frame(...) Cookies WebDriver .manage() .deleteAllCookies() Support .addCookie(Cookie) WebDriverWait ByChaining(By, By) .deleteCookie(Cookie) (driver, timeout in Seconds) .until(ExpectedCondition) ByIdOrName(“idName”) .deleteCookieNamed(String) ExpectedConditions .titleIs(String) … a lot of helper methods Cookies Actions (JavascriptExecutor) WebDriver .keyUp() etc. .executeScript .perform() .manage() .getCookieNamed(String) .getCookies() 68
  • 69. End Points   You will encounter problems we haven't covered here You will need to download and read the Selenium 2.0 source code as you test 69
  • 71. Advanced Practice Pages  http://compendiumdev.co.uk/selenium/   Showcase/Showcase.html Source available at https://bitbucket.org/ajrichardson/simplegwtshowcaseclone 71
  • 72. WebDriver Tutorial Reference Slides For More like this visit:  Http://seleniumsimplified.com  Online Course: http://unow.be/at/webdriverapi The reference slides are excerpts from the above online course 72