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

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 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/