SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
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
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__);

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

Contenu connexe

Tendances

Selenium tutorial
Selenium tutorialSelenium tutorial
Selenium tutorialmindqqa
 
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 HaeffnerApplitools
 
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 1Furqan 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 PluginsSamit Badle
 
Selenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSelenium Best Practices with Jason Huggins
Selenium Best Practices with Jason HugginsSauce Labs
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave 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 AutomationSauce Labs
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin MishraPravin Mishra
 
Apex Testing Deep Dive
Apex Testing Deep DiveApex Testing Deep Dive
Apex Testing Deep DiveAdam Olshansky
 
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 applicationsTSundberg
 
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 MeetupDave Haeffner
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With SeleniumDeepak Mittal
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 

Tendances (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
 

Similaire à Selenium 101: Automates browsers

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 TricksDaniel Ballinger
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike 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 2012Michelangelo 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 tek12Michelangelo 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 CIwajrcs
 
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.NETBen 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
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Seleniumrohitnayak
 
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 - phpdublinMichelangelo van Dam
 
Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Seleniumjoaopmaia
 
Real World Selenium Testing
Real World Selenium TestingReal World Selenium Testing
Real World Selenium TestingMary 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 ExecutionpCloudy
 
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 frameworkSusannSgorzaly
 
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 pluginsAsif Mohaimen
 
Practical Generative Testing Patterns
Practical Generative Testing PatternsPractical Generative Testing Patterns
Practical Generative Testing PatternsSrihari Sriraman
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksLohika_Odessa_TechTalks
 

Similaire à Selenium 101: Automates browsers (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)
 
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
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
 

Dernier

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Dernier (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Selenium 101: Automates browsers

  • 1.
  • 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
  • 51.
  • 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__);
 }
  • 56.
  • 57. RESOURCES • http://www.seleniumhq.org/ • https://github.com/becoded/talk-selenium-101 • https://github.com/facebook/php-webdriver • http://magiumlib.com/