SlideShare a Scribd company logo
Selenium 101
SELENIUM 101
automates browsers
I’M
• BertVan Hauwaert
• CEO, CFO, CTO, … of
be.coded
• Freelancer
NOTICE
This is a 101 talk!
(ANTI-)PATTERNS
ICE-CREAM CONE
Manual tests
Automated
GUI tests
Integration
tests
Unit
tests
CUPCAKE
ManualTest
Automated GUITests
Automated IntegrationTests
(API, Component)
Automated
UnitTests
Manual testers
Automated GUI
testers
Developers
TESTING PYRAMID
Automated
GUI tests
Automated API tests
Automated Integration tests
Automated Component tests
Automated Unit tests
Manual
Session
BasedTesting
Functional tests
Examples
Story tests
Prototypes
Simulations
Exploratory testing
Scenarios
Usability testing
UAT
Alpha / Beta
Unit tests
Component test
Performance & Load testing
Security testing
“ility” testing
Business facing
Technology facing
Supportingtheteam
Critiqueproduct
Automated & manual
Automated
Manual
Tools
AGILETESTING QUADRANTS
Q2
Q1 Q4
Q3
BROWSERTESTING
• Headless browser emulators
• Browser controllers
WHAT IS SELENIUM?
• Suite of tools
• Automates browsers
• Testing purposes
• Boring web-based administration tasks
TOOLS - SELENIUM IDE
• Selenium IDE
• Firefox extension
• Record and playback interactions
• Use it to
• Create quick bug reproduction scripts
• Create scripts to aid in automation-aided exploratory
testing
TOOLS - SELENIUM RC
• Selenium Remote Control
• Server
• Automatically launches and kills browsers
• Acts as a HTTP proxy for web requests from them
• Client libraries
• for your favourite computer language
• Deprecated
TOOLS - SELENIUM WEBDRIVER
• Successor to Selenium RC
• Driving a browser natively
• Accepts commands > browser
• Sent in Selenese or Client API
• Using a browser driver
TOOLS - SELENIUM GRID
• Web browsers on remote machines
• One server acts as a hub
• Tests contact hub to access browsers
• Running tests in parallel
THE IDE
THE IDE
COMMANDS
• Selenese
• 3 types
• Actions
• Accessors
• Assertions
SCRIPT SYNTAX
• Command + 2 parameters
• Not always required
• Parameters
• Locator
• Text pattern to verify
• Text pattern or variable to insert
LOCATOR
• Identifies an element
• identifier
• id
• name
• XPath
• link text
• DOM
• CSS
LOCATOR - IDENTIFIER
• identifier=loginForm
• identifier=password
• identifier=continue
• username

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - ID
• id=loginForm

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - NAME
• name=username
• name=continue
• name=continue value=Clear
• name=continue Clear
• name=continue type=button

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - XPATH
• xpath=/html/body/form[1]
• //form[1]
• xpath=//form[@id='loginForm']
• xpath=//form[input/@name='username']

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - XPATH
• //input[@name='username']
• //form[@id='loginForm']/input[1]

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - XPATH
• //input[@name='continue'][@type='button']
• //form[@id='loginForm']/input[4]

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - LINK
• link=Register

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - DOM
• dom=document.getElementById('loginForm')
• dom=document.forms['loginForm']
• dom=document.forms[0]

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - DOM
• document.forms[0].username
• document.forms[0].elements['username']
• document.forms[0].elements[0]

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - DOM
• document.forms[0].elements[3]

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - CSS
• css=form#loginForm

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - CSS
• css=input[name="username"]
• css=input.req[type="text"] 

<html>
<body>
<form id="loginForm">
<input class=“req” name="username" type="text"/>
<input class="req pwd" name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - CSS
• css=input.pwd
• css=#loginForm input:nth-child(2)

<html>
<body>
<form id="loginForm">
<input class="req" name="username" type="text"/>
<input class="req pwd" name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
LOCATOR - CSS
• css=#loginForm input[type="button"]

<html>
<body>
<form id="loginForm">
<input name="username" type="text"/>
<input name="password" type="password"/>
<input name="continue" type="submit" value="Login"/>
<input name="continue" type="button" value="Clear"/>
</form>
<a href="/pleaseSendMeSpam">Register</a>
</body>
<html>
TEXT PATTERNS
• Globbing
• Regular expressions
• Exact
TEXT PATTERNS - GLOBBING
• glob:
• *
• Match anything inside character class
• [ ]
• Character class
• [aeiou]
• [0-9]
• [a-zA-Z0-9]
TEXT PATTERNS – REGULAR
EXPRESSIONS
• regexp: or regexpi:
PATTERN MATCH
. any single character
[ ] character class: any single character that appears inside the brackets
* quantifier: 0 or more of the preceding character (or group)
+ quantifier: 1 or more of the preceding character (or group)
? quantifier: 0 or 1 of the preceding character (or group)
{1,5} quantifier: 1 through 5 of the preceding character (or group)
|
alternation: the character/group on the left or the character/group on the
right
( ) grouping: often used with alternation and/or quantifier
TEXT PATTERNS - EXACT
• Exact:
• “Real *”
• glob:Real * will also match “Real number”
• exact:Real *
• regexp:Real *
TEST CASE
• Set of Selenium commands
• Executed one by one
TEST SUITES
• A test suite is a collection of tests
• <html>

<head> 

<title>Test Suite Function Tests - Priority 1</title> 

</head> 

<body> 

<table>

<tr><td><b>Suite Of Tests</b></td></tr>

<tr><td><a href="./ultimateQuestionOfLive.html">Ultimate question of live</a></td></tr>

<tr><td><a href="./recursion.html">Recursion</a></td></tr>

</table>

</body>

</html>
COMMONLY USED
COMMANDS
• open
• opens a page using a URL.
• click/clickAndWait
• performs a click operation, and optionally waits for a new page to load.
• waitForPageToLoad
• pauses execution until an expected new page loads. Called automatically when
clickAndWait is used.
• waitForElementPresent
• pauses execution until an expected UI element, as defined by its HTML tag, is present
on the page.
COMMONLY USED
COMMANDS
• verifyTitle/assertTitle
• verifies an expected page title.
• verifyTextPresent
• verifies expected text is somewhere on the page.
• verifyElementPresent
• verifies an expected UI element, as defined by its HTML tag, is present on the
page.
• verifyText
• verifies expected text and its corresponding HTML tag are present on the page.
ASSERTION ORVERIFICATION
• Assert
• Fail test, abort current test case
• Verify
• Fail test, continue to run the test case
TIP - BASEURL
<tr>

<td>store</td>

<td>http://domain</td>

<td>baseUrl</td>

</tr>



<! – … -->



<tr>

<td>open</td>

<td>${baseUrl}/page</td>

<td></td>

</tr>
TIP – OVERWRITE METHOD
<tr>
<td>getEval</td>
<td>window._oldFooBar = window.fooBar;
window.fooBar = function(arg1, arg2) {
window._oldFooBar(arg1, arg2);
window.fooBarData = {
arg1: arg1,
arg2: arg2
};
if (window.console){
window.console.log(window.fooBarData);
}
};</td>
<td></td>
</tr>
TIP – OVERWRITE METHOD
<tr>
<td>assertEval</td>
<td>window.fooBarData.arg1</td>
<td>baz</td>
</tr>
TIP – NO ORPHANEDTEXT
<a href=“/property/123”>
Koekoekstraat 70 - Melle
<em>235.000 EUR</em>
</a>
<a href=“/property/123”>
<span>Koekoekstraat 70 - Melle</span>
<em>235.000 EUR</em>
</a>
TIP – IDENTIFY FUNCTION
<button id="login-button">
<span>Login</span>
</button>
WAI-ARIA role landmarks
//li[@role="menuitem" and .=“About us ,”]
TIP – MAGNIUM
• Magium = Selenium + Magento
DEMO
• Answer to the Ultimate Question of Life, the
Universe, and Everything
• Recursion
Selenium 101
DOCKERTOTHE RESCUE
• https://hub.docker.com/r/selenium/
• selenium/hub
• selenium/node-chrome
• selenium/node-firefox
DOCKER-COMPOSE
hub:
image: selenium/hub
ports:
- "4444:4444"
firefox:
image: selenium/node-firefox
links:
- hub
chrome:
image: selenium/node-chrome
links:
- hub
EXAMPLE
abstract class AbstractSeleniumTestCase extends TestCase

{



protected $webDriverUrl = ‘http://127.0.0.1:4444/wd/hub';

protected $webDriver;



public function setUp()

{

$this->webDriver = RemoteWebDriver::create(
$this->webDriverUrl, DesiredCapabilities::firefox()
);

}



public function tearDown()

{

if ($this->webDriver) {

$this->webDriver->quit();


}

}
}
EXAMPLE
public function testRecursion()

{

$this->webDriver->get('http://www.google.be');

$this->webDriver->findElement(WebDriverBy::id('lst-ib'))

->sendKeys('Recursion')->submit();



$this->webDriver->wait(10, 300)

->until(

function ($webDriver) {

try {

$webDriver->findElement(WebDriverBy::cssSelector('a.spell'));

return true;

} catch (NoSuchElementException $ex) {

return false;

}

}

);



$aSpellElement = $this->webDriver->findElement(WebDriverBy::cssSelector('a.spell'));

$this->assertEquals("Recursion", $aSpellElement->getText());

$aSpellElement->click();

$this->takeScreenshot(__FUNCTION__);

}
Selenium 101
RESOURCES
• http://www.seleniumhq.org/
• https://github.com/becoded/talk-selenium-101
• https://github.com/facebook/php-webdriver
• http://magiumlib.com/
QUESTIONS ?

More Related Content

What's hot

Selenium classes in mumbai
Selenium classes in mumbaiSelenium classes in mumbai
Selenium classes in mumbai
Vibrant Technologies & Computers
 
Selenium tutorial
Selenium tutorialSelenium tutorial
Selenium tutorial
mindqqa
 
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave HaeffnerPractical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Applitools
 
Learn Test Automation using Selenium - Lesson 1
Learn Test Automation using Selenium - Lesson 1Learn Test Automation using Selenium - Lesson 1
Learn Test Automation using Selenium - Lesson 1
Furqan Ud Din
 
Efficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE PluginsEfficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE Plugins
Samit Badle
 
Selenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSelenium Best Practices with Jason Huggins
Selenium Best Practices with Jason Huggins
Sauce Labs
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
Dave Haeffner
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Sauce Labs
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin Mishra
Pravin Mishra
 
Selenium
SeleniumSelenium
Selenium
Andrew Krug
 
Selenium IDE features
Selenium IDE featuresSelenium IDE features
Selenium IDE features
onewomanmore witl
 
Apex Testing Deep Dive
Apex Testing Deep DiveApex Testing Deep Dive
Apex Testing Deep Dive
Adam Olshansky
 
Selenium ide made easy
Selenium ide made easySelenium ide made easy
Selenium ide made easy
Narayanan Palani
 
Selenium
SeleniumSelenium
Selenium
Adam Goucher
 
Selenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsSelenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applications
TSundberg
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
Selenium IDE
Selenium IDESelenium IDE
Selenium IDE
brendon_jag
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
Deepak Mittal
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
Dave Haeffner
 

What's hot (19)

Selenium classes in mumbai
Selenium classes in mumbaiSelenium classes in mumbai
Selenium classes in mumbai
 
Selenium tutorial
Selenium tutorialSelenium tutorial
Selenium tutorial
 
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave HaeffnerPractical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
 
Learn Test Automation using Selenium - Lesson 1
Learn Test Automation using Selenium - Lesson 1Learn Test Automation using Selenium - Lesson 1
Learn Test Automation using Selenium - Lesson 1
 
Efficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE PluginsEfficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE Plugins
 
Selenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSelenium Best Practices with Jason Huggins
Selenium Best Practices with Jason Huggins
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin Mishra
 
Selenium
SeleniumSelenium
Selenium
 
Selenium IDE features
Selenium IDE featuresSelenium IDE features
Selenium IDE features
 
Apex Testing Deep Dive
Apex Testing Deep DiveApex Testing Deep Dive
Apex Testing Deep Dive
 
Selenium ide made easy
Selenium ide made easySelenium ide made easy
Selenium ide made easy
 
Selenium
SeleniumSelenium
Selenium
 
Selenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsSelenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applications
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
 
Selenium IDE
Selenium IDESelenium IDE
Selenium IDE
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 

Similar to Selenium 101

Dreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and TricksDreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and Tricks
Daniel Ballinger
 
Selenium.ppt
Selenium.pptSelenium.ppt
Selenium.ppt
onlinemindq
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
Mike Lively
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
Michelangelo van Dam
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
Michelangelo van Dam
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
wajrcs
 
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Edureka!
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
Ben Hall
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
Jen Wong
 
cypress course slides e2e automatic testing .pptx
cypress course slides e2e automatic testing .pptxcypress course slides e2e automatic testing .pptx
cypress course slides e2e automatic testing .pptx
MuhammadSaadBashir2
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Selenium
rohitnayak
 
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublin
Michelangelo van Dam
 
Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Selenium
joaopmaia
 
Selenium
SeleniumSelenium
Selenium
kalyan234
 
Real World Selenium Testing
Real World Selenium TestingReal World Selenium Testing
Real World Selenium Testing
Mary Jo Sminkey
 
Appium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionAppium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation Execution
pCloudy
 
Testing mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP framework
SusannSgorzaly
 
Clean tests good tests
Clean tests   good testsClean tests   good tests
Clean tests good tests
Shopsys Framework
 
Intro to Selenium UI Tests with pytest & some useful pytest plugins
Intro to Selenium UI Tests with pytest & some useful pytest pluginsIntro to Selenium UI Tests with pytest & some useful pytest plugins
Intro to Selenium UI Tests with pytest & some useful pytest plugins
Asif Mohaimen
 
Practical Generative Testing Patterns
Practical Generative Testing PatternsPractical Generative Testing Patterns
Practical Generative Testing Patterns
Srihari Sriraman
 

Similar to Selenium 101 (20)

Dreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and TricksDreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and Tricks
 
Selenium.ppt
Selenium.pptSelenium.ppt
Selenium.ppt
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
 
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
cypress course slides e2e automatic testing .pptx
cypress course slides e2e automatic testing .pptxcypress course slides e2e automatic testing .pptx
cypress course slides e2e automatic testing .pptx
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Selenium
 
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublin
 
Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Real World Selenium Testing
Real World Selenium TestingReal World Selenium Testing
Real World Selenium Testing
 
Appium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionAppium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation Execution
 
Testing mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP framework
 
Clean tests good tests
Clean tests   good testsClean tests   good tests
Clean tests good tests
 
Intro to Selenium UI Tests with pytest & some useful pytest plugins
Intro to Selenium UI Tests with pytest & some useful pytest pluginsIntro to Selenium UI Tests with pytest & some useful pytest plugins
Intro to Selenium UI Tests with pytest & some useful pytest plugins
 
Practical Generative Testing Patterns
Practical Generative Testing PatternsPractical Generative Testing Patterns
Practical Generative Testing Patterns
 

Recently uploaded

Opencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of MünsterOpencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of Münster
Matthias Neugebauer
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
Brian Pichman
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
SAI KAILASH R
 
Integrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecaseIntegrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecase
shyamraj55
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
AmandaCheung15
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
shanihomely
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
Razin Mustafiz
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
DianaGray10
 
Finetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and DefendingFinetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and Defending
Priyanka Aash
 
Camunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptxCamunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptx
ZachWylie3
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
Steven Carlson
 
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
alexjohnson7307
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
ankush9927
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
Zilliz
 
Tailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer InsightsTailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer Insights
SynapseIndia
 
Patch Tuesday de julio
Patch Tuesday de julioPatch Tuesday de julio
Patch Tuesday de julio
Ivanti
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
Zilliz
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
BrainSell Technologies
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
bellared2
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
Enterprise Knowledge
 

Recently uploaded (20)

Opencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of MünsterOpencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of Münster
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
 
Integrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecaseIntegrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecase
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
 
Finetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and DefendingFinetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and Defending
 
Camunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptxCamunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptx
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
 
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
 
Tailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer InsightsTailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer Insights
 
Patch Tuesday de julio
Patch Tuesday de julioPatch Tuesday de julio
Patch Tuesday de julio
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
 

Selenium 101

  • 3. I’M • BertVan Hauwaert • CEO, CFO, CTO, … of be.coded • Freelancer
  • 4. NOTICE This is a 101 talk!
  • 6. ICE-CREAM CONE Manual tests Automated GUI tests Integration tests Unit tests
  • 7. CUPCAKE ManualTest Automated GUITests Automated IntegrationTests (API, Component) Automated UnitTests Manual testers Automated GUI testers Developers
  • 8. TESTING PYRAMID Automated GUI tests Automated API tests Automated Integration tests Automated Component tests Automated Unit tests Manual Session BasedTesting
  • 9. Functional tests Examples Story tests Prototypes Simulations Exploratory testing Scenarios Usability testing UAT Alpha / Beta Unit tests Component test Performance & Load testing Security testing “ility” testing Business facing Technology facing Supportingtheteam Critiqueproduct Automated & manual Automated Manual Tools AGILETESTING QUADRANTS Q2 Q1 Q4 Q3
  • 10. BROWSERTESTING • Headless browser emulators • Browser controllers
  • 11. WHAT IS SELENIUM? • Suite of tools • Automates browsers • Testing purposes • Boring web-based administration tasks
  • 12. TOOLS - SELENIUM IDE • Selenium IDE • Firefox extension • Record and playback interactions • Use it to • Create quick bug reproduction scripts • Create scripts to aid in automation-aided exploratory testing
  • 13. TOOLS - SELENIUM RC • Selenium Remote Control • Server • Automatically launches and kills browsers • Acts as a HTTP proxy for web requests from them • Client libraries • for your favourite computer language • Deprecated
  • 14. TOOLS - SELENIUM WEBDRIVER • Successor to Selenium RC • Driving a browser natively • Accepts commands > browser • Sent in Selenese or Client API • Using a browser driver
  • 15. TOOLS - SELENIUM GRID • Web browsers on remote machines • One server acts as a hub • Tests contact hub to access browsers • Running tests in parallel
  • 18. COMMANDS • Selenese • 3 types • Actions • Accessors • Assertions
  • 19. SCRIPT SYNTAX • Command + 2 parameters • Not always required • Parameters • Locator • Text pattern to verify • Text pattern or variable to insert
  • 20. LOCATOR • Identifies an element • identifier • id • name • XPath • link text • DOM • CSS
  • 21. LOCATOR - IDENTIFIER • identifier=loginForm • identifier=password • identifier=continue • username
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 22. LOCATOR - ID • id=loginForm
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 23. LOCATOR - NAME • name=username • name=continue • name=continue value=Clear • name=continue Clear • name=continue type=button
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 24. LOCATOR - XPATH • xpath=/html/body/form[1] • //form[1] • xpath=//form[@id='loginForm'] • xpath=//form[input/@name='username']
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 25. LOCATOR - XPATH • //input[@name='username'] • //form[@id='loginForm']/input[1]
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 26. LOCATOR - XPATH • //input[@name='continue'][@type='button'] • //form[@id='loginForm']/input[4]
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 27. LOCATOR - LINK • link=Register
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 28. LOCATOR - DOM • dom=document.getElementById('loginForm') • dom=document.forms['loginForm'] • dom=document.forms[0]
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 29. LOCATOR - DOM • document.forms[0].username • document.forms[0].elements['username'] • document.forms[0].elements[0]
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 30. LOCATOR - DOM • document.forms[0].elements[3]
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 31. LOCATOR - CSS • css=form#loginForm
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 32. LOCATOR - CSS • css=input[name="username"] • css=input.req[type="text"] 
 <html> <body> <form id="loginForm"> <input class=“req” name="username" type="text"/> <input class="req pwd" name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 33. LOCATOR - CSS • css=input.pwd • css=#loginForm input:nth-child(2)
 <html> <body> <form id="loginForm"> <input class="req" name="username" type="text"/> <input class="req pwd" name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 34. LOCATOR - CSS • css=#loginForm input[type="button"]
 <html> <body> <form id="loginForm"> <input name="username" type="text"/> <input name="password" type="password"/> <input name="continue" type="submit" value="Login"/> <input name="continue" type="button" value="Clear"/> </form> <a href="/pleaseSendMeSpam">Register</a> </body> <html>
  • 35. TEXT PATTERNS • Globbing • Regular expressions • Exact
  • 36. TEXT PATTERNS - GLOBBING • glob: • * • Match anything inside character class • [ ] • Character class • [aeiou] • [0-9] • [a-zA-Z0-9]
  • 37. TEXT PATTERNS – REGULAR EXPRESSIONS • regexp: or regexpi: PATTERN MATCH . any single character [ ] character class: any single character that appears inside the brackets * quantifier: 0 or more of the preceding character (or group) + quantifier: 1 or more of the preceding character (or group) ? quantifier: 0 or 1 of the preceding character (or group) {1,5} quantifier: 1 through 5 of the preceding character (or group) | alternation: the character/group on the left or the character/group on the right ( ) grouping: often used with alternation and/or quantifier
  • 38. TEXT PATTERNS - EXACT • Exact: • “Real *” • glob:Real * will also match “Real number” • exact:Real * • regexp:Real *
  • 39. TEST CASE • Set of Selenium commands • Executed one by one
  • 40. TEST SUITES • A test suite is a collection of tests • <html>
 <head> 
 <title>Test Suite Function Tests - Priority 1</title> 
 </head> 
 <body> 
 <table>
 <tr><td><b>Suite Of Tests</b></td></tr>
 <tr><td><a href="./ultimateQuestionOfLive.html">Ultimate question of live</a></td></tr>
 <tr><td><a href="./recursion.html">Recursion</a></td></tr>
 </table>
 </body>
 </html>
  • 41. COMMONLY USED COMMANDS • open • opens a page using a URL. • click/clickAndWait • performs a click operation, and optionally waits for a new page to load. • waitForPageToLoad • pauses execution until an expected new page loads. Called automatically when clickAndWait is used. • waitForElementPresent • pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.
  • 42. COMMONLY USED COMMANDS • verifyTitle/assertTitle • verifies an expected page title. • verifyTextPresent • verifies expected text is somewhere on the page. • verifyElementPresent • verifies an expected UI element, as defined by its HTML tag, is present on the page. • verifyText • verifies expected text and its corresponding HTML tag are present on the page.
  • 43. ASSERTION ORVERIFICATION • Assert • Fail test, abort current test case • Verify • Fail test, continue to run the test case
  • 44. TIP - BASEURL <tr>
 <td>store</td>
 <td>http://domain</td>
 <td>baseUrl</td>
 </tr>
 
 <! – … -->
 
 <tr>
 <td>open</td>
 <td>${baseUrl}/page</td>
 <td></td>
 </tr>
  • 45. TIP – OVERWRITE METHOD <tr> <td>getEval</td> <td>window._oldFooBar = window.fooBar; window.fooBar = function(arg1, arg2) { window._oldFooBar(arg1, arg2); window.fooBarData = { arg1: arg1, arg2: arg2 }; if (window.console){ window.console.log(window.fooBarData); } };</td> <td></td> </tr>
  • 46. TIP – OVERWRITE METHOD <tr> <td>assertEval</td> <td>window.fooBarData.arg1</td> <td>baz</td> </tr>
  • 47. TIP – NO ORPHANEDTEXT <a href=“/property/123”> Koekoekstraat 70 - Melle <em>235.000 EUR</em> </a> <a href=“/property/123”> <span>Koekoekstraat 70 - Melle</span> <em>235.000 EUR</em> </a>
  • 48. TIP – IDENTIFY FUNCTION <button id="login-button"> <span>Login</span> </button> WAI-ARIA role landmarks //li[@role="menuitem" and .=“About us ,”]
  • 49. TIP – MAGNIUM • Magium = Selenium + Magento
  • 50. DEMO • Answer to the Ultimate Question of Life, the Universe, and Everything • Recursion
  • 52. DOCKERTOTHE RESCUE • https://hub.docker.com/r/selenium/ • selenium/hub • selenium/node-chrome • selenium/node-firefox
  • 53. DOCKER-COMPOSE hub: image: selenium/hub ports: - "4444:4444" firefox: image: selenium/node-firefox links: - hub chrome: image: selenium/node-chrome links: - hub
  • 54. EXAMPLE abstract class AbstractSeleniumTestCase extends TestCase
 {
 
 protected $webDriverUrl = ‘http://127.0.0.1:4444/wd/hub';
 protected $webDriver;
 
 public function setUp()
 {
 $this->webDriver = RemoteWebDriver::create( $this->webDriverUrl, DesiredCapabilities::firefox() );
 }
 
 public function tearDown()
 {
 if ($this->webDriver) {
 $this->webDriver->quit(); 
 }
 } }
  • 55. EXAMPLE public function testRecursion()
 {
 $this->webDriver->get('http://www.google.be');
 $this->webDriver->findElement(WebDriverBy::id('lst-ib'))
 ->sendKeys('Recursion')->submit();
 
 $this->webDriver->wait(10, 300)
 ->until(
 function ($webDriver) {
 try {
 $webDriver->findElement(WebDriverBy::cssSelector('a.spell'));
 return true;
 } catch (NoSuchElementException $ex) {
 return false;
 }
 }
 );
 
 $aSpellElement = $this->webDriver->findElement(WebDriverBy::cssSelector('a.spell'));
 $this->assertEquals("Recursion", $aSpellElement->getText());
 $aSpellElement->click();
 $this->takeScreenshot(__FUNCTION__);
 }
  • 57. RESOURCES • http://www.seleniumhq.org/ • https://github.com/becoded/talk-selenium-101 • https://github.com/facebook/php-webdriver • http://magiumlib.com/