SlideShare a Scribd company logo
1 of 59
Nick Belhomme January 26th,   PHPBenelux Conference 2013, Belgium
Nick Belhomme
International Conference Speaker


Contributor to various Open Source
Projects


Building Constructor


Software Architect / Project Lead


Loving Husband


Freelance PHP Consultant


PHP QA trainer


Your host for the upcoming hour
Selenium
       34
    Claims, Benefits:

    Prevents cancer

    Aging
Selenium – the web browser
automation tool set
Acceptance Tests
●   System tests
●   Black box
●   Functional testing
Browser Compatibility Tests
●   Different Browsers
●   Different Operating Systems
Regression Tests

●   Internal Changes
●   Partner Changes
Tools
●   Humans
●   Capture and replay
●   Scripts and bots
●   Selenium
Manual Testing
●   Time-intensive
●   Nerve-stretching
●   Human error / understanding of the flow
●   Costly
Capture and Replay
●   Captures mouse movements and inputs
●   Replays later
●   Screenresolution, operating systems, window
    sizes, makes this very unmaintainable
Scripts and Bots
●   Bot makes screen-shots, analyzes them for
    visual blocks
●   Calculates visual blocks x-y positions and
    generates mouse clicks on that location and
    user input.
●   Generating a test is time-intensive
●   Error prone on design changes.
Selenium
●   Records and playback browser tests
●   Asserts on DOM
●   Javascript is being executed and testable
●   Css selectors or xpath position sensitive
●   Hard to detect layout errors
Learning Curve

●   Jump in quickly
●   Steep – If you want to do it right
●   Mastering it – creating readable,
    understandable, maintainable and robust tests -
    takes time and effort.
Worth it

           Ask a Salary
           Increase
           and
           own a second
           modest
           vacation property
And as an added bonus
●   Better code architecture
●   More functional code
●   High browser compatibility
●   No more regressions
●   Neat cool stuff to brag about at your local pub!!!
Setting it up client side
Selenium IDE
    Firefox Plugin:
    http://release.seleniumhq.org/selenium-ide/1.10.0/selenium-ide-1.10.0.xpi


●
    Easy record and playback
●   Intelligent field selection will use IDs, names, or XPath as needed
●
    Autocomplete for all common Selenium commands
●   Walk through tests
●
    Debug and set breakpoints
●   Save tests as HTML, PHPUnit, or any other format
●
    Support for Selenium user-extensions.js file
●
    Option to automatically assert the title of every page
●
    Easy customization through plugins
Selenium IDE
Test Suite Control Flow
X-forwarding
    run software on remote machine and display the GUI locally


●   Linux and Mac OS X support X Forwarding with no extra
    software
       ssh -X
●   Windows needs extra software
       Xming
Xming
                     (X-forwarding for windows)

http://sourceforge.net/projects/xming/files/latest/download

Configure Xming
   Windows Start => Xming => XLaunch
   Display settings dialog box:
     Multiple windows
     Display number as 0
   Keep clicking next then Finish.
Putty (windows)



●   Connection => SSH => X11
●   Enable X11 forwarding
●   Set X display location as :0.0
Setting it up server side
       (headless)
Firefox

●   [64 bit] wget
    http://download-origin.cdn.mozilla.net/pub/mozilla.org/firefox/relea
●   [32 bit] wget
    http://download-origin.cdn.mozilla.net/pub/mozilla.org/firefox/relea

●   tar -jxvf firefox-18.0.tar.bz2 -C /opt
●   ln -s /opt/firefox/firefox /usr/bin/firefox
●
    Firefox (No X-Display needed thanks to forwarding)
Completely headless
              (no X-forwarding)
●   Install Xvfb
      aptitude install Xvfb
●   Update to latest java version
      aptitude install sun-java6-jre
●   Download the latest Selenium Server Jar
    package
      wget http://selenium.googlecode.com/files/selenium-
      server-standalone-2.28.0.jar
Test driving Selenium RC
                (X-forwarding)

To test-drive it is always easier to first use X-forwarding:


java -jar selenium-server-standalone-2.28.0.jar -htmlSuite
*firefox "http://www.domaintocheck.com"
“/path/to/selenium/testSuite.html”
“/path/where/selenium/should/store/results.html”

testSuite.html and related files are the files saved by Selenium IDE
Test driving Selenium RC
           (X Virtual Frame Buffer)
●   Open a connection and run Xvfb
      Xvfb :99


●   Open another connection and run selenium

    export DISPLAY=:99 & java -jar selenium-server-
    standalone-2.28.0.jar -htmlSuite *firefox
    "http://www.domaintocheck.com"
    “/path/to/selenium/testSuite.html”
    “/path/where/selenium/should/store/results.html”
Integrate into



    Make certain your Jenkins server is started with Xvfb run on :99
    ●   Check with:
            ps -ef | grep Xvfb
    ●   If not running then issue a
          Xvfb :99
          CTRL + Z
●   Log into Jenkins: manage Jenkins -> Manage Plugins
        install “Hudson Seleniumhq plugin”
Setup a Job
●   Create a new freestyle job
Problem
●   remote control is slow at driving the browser.

●   limited number of concurrent tests on the same
    remote control before seriously impacting its
    stability.

●   Multiple Selenium Remote Controls In Jenkins
    to work around the limitation on the number of
    parallel tests.
The Grid

●   Run tests against multiple browsers

●   multiple versions of browser

●   browsers running on different operating systems

●   To reduce the time it takes for the test suite to
    complete a test pass.
The Hub
●   1 instance

●   Allocating a Selenium Remote Control to a specific
    test (transparently)

●   Limiting the number of concurrent test runs on each
    Remote Control

●   Shielding the tests from the actual grid
    infrastructure
A Node
●   Remote Control

●   Multiple instances (across machines preferably)

●   Multiple Browsers

●   Can be configured using a json file
Setting up the grid
●   Start the hub
      java -jar selenium-server-standalone-2.28.0.jar -role hub



●   Start nodes on separate machines
      java -jar selenium-server-standalone-2.28.0.jar -role
      node -hub http://hub-address:4444/grid/register
http://hub-address:4444/grid/console
Optimizing a Node with js
     ●   java -jar selenium-server-standalone-2.28.0.jar -role node -nodeConfig nodeConfig.js


    //nodeConfig.js
{
    "class":"org.openqa.grid.common.RegistrationRequest",
    "capabilities":[
         {
              "platform":"VISTA",
              "seleniumProtocol":"Selenium",
              "browserName":"*firefox",
              "maxInstances":5
         },
         {
              "platform":"VISTA",
              "seleniumProtocol":"Selenium",
              "browserName":"*iexplore",
              "maxInstances":1
         }
    ],
"configuration":{
        "port":5555,
        "register":true,
        "host":"node-address",
        "proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession":5,
        "role":"node",
        "hubHost":"hub-address",
        "registerCycle":5000,
        "hub":"http://hub-address:4444/grid/register",
        "hubPort":4444,
        "url":"http://node-address:5555",
        "remoteHost":"http://node-address:5555"
    }
}
http://hub-address:4444/grid/console
Run the suite
●   No Native HTML Selenese tests support

●   Web driver needed

●   PHPUnit
+ Selenium Web Driver

wget http://pear.phpunit.de/get/phpunit.phar
chmod +x phpunit.phar
Selenium-ide-php-formatters

Convert Html Selenese tests to PHPUnit test
cases


Firefox Addon:
https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-
php-formatters/
Export the Test Cases
The test case

<?php
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*iexplore");
    $this->setBrowserUrl("http://www.nickbelhomme.com/");
  }

 public function testMyTestCase()
 {
   $this->open("/");
   $this->assertTrue($this->isElementPresent("link=About"));
   $this->assertTrue($this->isElementPresent("link=Consulting & Training"));
   $this->assertTrue($this->isElementPresent("link=Blog"));
   $this->assertTrue($this->isElementPresent("link=Contact"));
   $name = $this->getEval(""nick"==="nick"");
 }
}
?>
Run the test case
php phpunit.phar testcases/testMenu.php




      Run the test suite
      php phpunit.phar testcases
Use multiple browsers
public static $browsers = array(
  array(
    'name' => 'Firefox',
    'browser' => '*firefox',
    'host' => 'hub-address',
    'port' => 4444,
    'timeout' => 30000,
  ),
  array(
    'name' => 'Internet Explorer',
    'browser' => '*iexplore',
    'host' => 'hub-address',
    'port' => 4444,
    'timeout' => 30000,
  )
);

protected function setUp()
{
  $this->setBrowserUrl('http://www.example.com/');
}
Use raw Html Selenese test

   public function testMenu()
   {
     $this->runSelenese('testMenu.html')
   }




Use raw Html Selenese testsuite

  public static $seleneseDirectory = '/path/to/files';
Taking it Parallel
With Paratest
    Parallel PHPUnit – running tests concurrently


●   Support for annotated tests
●   Inheritance
●   Tests suites
●   Test methods
●   Reflection driven
composer install
    // composer.json
{
     "require": {
          "brianium/paratest": "dev-master",
          "phpunit/dbunit": ">=1.2",
          "phpunit/php-invoker": "*",
          "phpunit/phpunit-selenium": ">=1.2",
          "phpunit/phpunit-story": "*"
     }
}
PHPUnit




Paratest + PHPUnit
References
●   X-Forwarding:
       http://en.gentoo-wiki.com/wiki/X-Forwarding
       http://www.straightrunning.com/XmingNotes/
●   Xvfb
       http://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml
●   Driving Selenium with PHPUnit
       http://www.phpunit.de/manual/3.8/en/selenium.html
●   Selenium Hq
       http://seleniumhq.org/docs/index.jsp
●   Composer
       http://getcomposer.org
●   Paratest
       http://brianscaturro.com/2012/11/02/parallel-phpunit.html
Troubleshooting
●   Firefox install dependencies
    http://www.thinkplexx.com/learn/howto/linux/system/installing-
    and-running-firefox-on-debian-linux-getting-missing-
    dependencies-shared-libs
●   Specify different ports in Jenkins for each RC when not using
    the grid
●   Proxy settings in Browser – use X-Forwarding to run Browser
    and change settings, use profile as a RC param when needed.
Link to slides and other updates is
            available at
http://www.facebook.com/NickBelhommeFanPage
The End!

                   THANK YOU
          Please rate my talk
          https://joind.in/7796
contact@nickbelhomme.com

Slideshare, Twitter, IRC: NickBelhomme

http://blog.nickbelhomme.com
Flickr Photo Credits
Backgrounds by Flikr
   http://www.flickr.com/photos/flikr/146538982/
   http://www.flickr.com/photos/flikr/147274362/

More Related Content

What's hot

Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using seleniumshreyas JC
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Selenium Ide Tutorial
Selenium Ide TutorialSelenium Ide Tutorial
Selenium Ide Tutorialmetapix
 
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Automated UI testing. Selenium. DrupalCamp Kyiv 2011Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Automated UI testing. Selenium. DrupalCamp Kyiv 2011Yuriy Gerasimov
 
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"Agile Testing Alliance
 
Selenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and WorkingSelenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and WorkingDisha Srivastava
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011hugs
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionSachin-QA
 
Automated UI testing with Selenium
Automated UI testing with SeleniumAutomated UI testing with Selenium
Automated UI testing with SeleniumYuriy Gerasimov
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With SeleniumDeepak Mittal
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing ToolZeba Tahseen
 
Selenium introduction
Selenium introductionSelenium introduction
Selenium introductionPankaj Dubey
 

What's hot (20)

Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Selenium Ide Tutorial
Selenium Ide TutorialSelenium Ide Tutorial
Selenium Ide Tutorial
 
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Automated UI testing. Selenium. DrupalCamp Kyiv 2011Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
 
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
#ATAGTR2021 Presentation - "Selenium 4 Observability – a 90 Min Hands on Lab"
 
Selenium
SeleniumSelenium
Selenium
 
Selenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and WorkingSelenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and Working
 
Selenium
SeleniumSelenium
Selenium
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Automated UI testing with Selenium
Automated UI testing with SeleniumAutomated UI testing with Selenium
Automated UI testing with Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
 
Selenium introduction
Selenium introductionSelenium introduction
Selenium introduction
 

Viewers also liked

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using SeleniumNaresh Chintalcheru
 
Splunk conf2014 - Using Selenium and Splunk for Transaction Monitoring Insight
Splunk conf2014 - Using Selenium and Splunk for Transaction Monitoring InsightSplunk conf2014 - Using Selenium and Splunk for Transaction Monitoring Insight
Splunk conf2014 - Using Selenium and Splunk for Transaction Monitoring InsightSplunk
 
Selenium Grid
Selenium GridSelenium Grid
Selenium Gridnirvdrum
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Seleniumvivek_prahlad
 
JAVA User Group Bern - Selenium
JAVA User Group Bern  - SeleniumJAVA User Group Bern  - Selenium
JAVA User Group Bern - SeleniumMichael Palotas
 
Automated Testing with Selenium
Automated Testing with SeleniumAutomated Testing with Selenium
Automated Testing with SeleniumRobert Kaiser
 
How to work with Selenium Grid: a quick walkthrough
How to work with Selenium Grid: a quick walkthroughHow to work with Selenium Grid: a quick walkthrough
How to work with Selenium Grid: a quick walkthroughNoam Zakai
 
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
 
SoftQL - Telecom Triage Services
SoftQL - Telecom Triage Services SoftQL - Telecom Triage Services
SoftQL - Telecom Triage Services Amar Uppalapati
 
Selenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web ApplicationsSelenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web Applicationsqooxdoo
 
淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)Kyle Lin
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver TutorialSelenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver TutorialAlan Richardson
 
Mobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsMobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsSauce Labs
 
Selenium Antipatterns
Selenium AntipatternsSelenium Antipatterns
Selenium AntipatternsJumpei Miyata
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 

Viewers also liked (20)

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Splunk conf2014 - Using Selenium and Splunk for Transaction Monitoring Insight
Splunk conf2014 - Using Selenium and Splunk for Transaction Monitoring InsightSplunk conf2014 - Using Selenium and Splunk for Transaction Monitoring Insight
Splunk conf2014 - Using Selenium and Splunk for Transaction Monitoring Insight
 
Selenium Grid
Selenium GridSelenium Grid
Selenium Grid
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
JAVA User Group Bern - Selenium
JAVA User Group Bern  - SeleniumJAVA User Group Bern  - Selenium
JAVA User Group Bern - Selenium
 
Automated Testing with Selenium
Automated Testing with SeleniumAutomated Testing with Selenium
Automated Testing with Selenium
 
How to work with Selenium Grid: a quick walkthrough
How to work with Selenium Grid: a quick walkthroughHow to work with Selenium Grid: a quick walkthrough
How to work with Selenium Grid: a quick walkthrough
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 
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
 
Meet the Selenium Grid
Meet the Selenium GridMeet the Selenium Grid
Meet the Selenium Grid
 
SoftQL - Telecom Triage Services
SoftQL - Telecom Triage Services SoftQL - Telecom Triage Services
SoftQL - Telecom Triage Services
 
Selenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web ApplicationsSelenium RC: Automated Testing of Modern Web Applications
Selenium RC: Automated Testing of Modern Web Applications
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)淺談 Geb 網站自動化測試(JCConf 2014)
淺談 Geb 網站自動化測試(JCConf 2014)
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver TutorialSelenium Clinic Eurostar 2012 WebDriver Tutorial
Selenium Clinic Eurostar 2012 WebDriver Tutorial
 
Mobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsMobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason Huggins
 
Selenium Antipatterns
Selenium AntipatternsSelenium Antipatterns
Selenium Antipatterns
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 

Similar to Mastering selenium for automated acceptance tests

Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolutionWise Engineering
 
Introduction to Selenium grid
Introduction to Selenium gridIntroduction to Selenium grid
Introduction to Selenium gridKnoldus Inc.
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Selenium grid workshop london 2016
Selenium grid workshop london 2016Selenium grid workshop london 2016
Selenium grid workshop london 2016Marcus Merrell
 
Testing Web Apps With Scripting Language - Mark Rees, Century Software
Testing Web Apps With Scripting Language - Mark Rees, Century SoftwareTesting Web Apps With Scripting Language - Mark Rees, Century Software
Testing Web Apps With Scripting Language - Mark Rees, Century SoftwareLinuxmalaysia Malaysia
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
How to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environmentHow to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environmentMichelantonio Trizio
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Bastian Feder
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAkshaya Mahapatra
 
Automated testing with Drupal
Automated testing with DrupalAutomated testing with Drupal
Automated testing with DrupalPromet Source
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScriptSimon Guest
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer ToolboxPablo Godel
 
Selenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI TestingSelenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI Testingmikereedell
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at ScaleKris Buytaert
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introductionvstorm83
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
Browser-Based testing using Selenium
Browser-Based testing using SeleniumBrowser-Based testing using Selenium
Browser-Based testing using Seleniumret0
 
Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using RubyKumari Warsha Goel
 

Similar to Mastering selenium for automated acceptance tests (20)

Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolution
 
Introduction to Selenium grid
Introduction to Selenium gridIntroduction to Selenium grid
Introduction to Selenium grid
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Selenium grid workshop london 2016
Selenium grid workshop london 2016Selenium grid workshop london 2016
Selenium grid workshop london 2016
 
Testing Web Apps With Scripting Language - Mark Rees, Century Software
Testing Web Apps With Scripting Language - Mark Rees, Century SoftwareTesting Web Apps With Scripting Language - Mark Rees, Century Software
Testing Web Apps With Scripting Language - Mark Rees, Century Software
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
How to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environmentHow to deploy a Java application on Google App engine Flexible environment
How to deploy a Java application on Google App engine Flexible environment
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps Approach
 
Automated testing with Drupal
Automated testing with DrupalAutomated testing with Drupal
Automated testing with Drupal
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 
Selenium
SeleniumSelenium
Selenium
 
Selenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI TestingSelenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI Testing
 
Deploying software at Scale
Deploying software at ScaleDeploying software at Scale
Deploying software at Scale
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Selenium Introduction
Selenium IntroductionSelenium Introduction
Selenium Introduction
 
Browser-Based testing using Selenium
Browser-Based testing using SeleniumBrowser-Based testing using Selenium
Browser-Based testing using Selenium
 
Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using Ruby
 

More from Nick Belhomme

Vagrant move over, here is Docker
Vagrant move over, here is DockerVagrant move over, here is Docker
Vagrant move over, here is DockerNick Belhomme
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?Nick Belhomme
 
PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxNick Belhomme
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHPNick Belhomme
 
Zend Framework Form: Mastering Decorators
Zend Framework Form: Mastering DecoratorsZend Framework Form: Mastering Decorators
Zend Framework Form: Mastering DecoratorsNick Belhomme
 
Zend Framework 1.8 workshop
Zend Framework 1.8 workshopZend Framework 1.8 workshop
Zend Framework 1.8 workshopNick Belhomme
 

More from Nick Belhomme (7)

Vagrant move over, here is Docker
Vagrant move over, here is DockerVagrant move over, here is Docker
Vagrant move over, here is Docker
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
 
PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBenelux
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHP
 
Cursus phpunit
Cursus phpunitCursus phpunit
Cursus phpunit
 
Zend Framework Form: Mastering Decorators
Zend Framework Form: Mastering DecoratorsZend Framework Form: Mastering Decorators
Zend Framework Form: Mastering Decorators
 
Zend Framework 1.8 workshop
Zend Framework 1.8 workshopZend Framework 1.8 workshop
Zend Framework 1.8 workshop
 

Recently uploaded

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
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
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
 
"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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
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
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Recently uploaded (20)

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
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
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)
 
"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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
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
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

Mastering selenium for automated acceptance tests

  • 1. Nick Belhomme January 26th, PHPBenelux Conference 2013, Belgium
  • 2. Nick Belhomme International Conference Speaker Contributor to various Open Source Projects Building Constructor Software Architect / Project Lead Loving Husband Freelance PHP Consultant PHP QA trainer Your host for the upcoming hour
  • 3. Selenium 34 Claims, Benefits: Prevents cancer Aging
  • 4. Selenium – the web browser automation tool set
  • 5. Acceptance Tests ● System tests ● Black box ● Functional testing
  • 6. Browser Compatibility Tests ● Different Browsers ● Different Operating Systems
  • 7. Regression Tests ● Internal Changes ● Partner Changes
  • 8. Tools ● Humans ● Capture and replay ● Scripts and bots ● Selenium
  • 9. Manual Testing ● Time-intensive ● Nerve-stretching ● Human error / understanding of the flow ● Costly
  • 10. Capture and Replay ● Captures mouse movements and inputs ● Replays later ● Screenresolution, operating systems, window sizes, makes this very unmaintainable
  • 11. Scripts and Bots ● Bot makes screen-shots, analyzes them for visual blocks ● Calculates visual blocks x-y positions and generates mouse clicks on that location and user input. ● Generating a test is time-intensive ● Error prone on design changes.
  • 12. Selenium ● Records and playback browser tests ● Asserts on DOM ● Javascript is being executed and testable ● Css selectors or xpath position sensitive ● Hard to detect layout errors
  • 13. Learning Curve ● Jump in quickly ● Steep – If you want to do it right ● Mastering it – creating readable, understandable, maintainable and robust tests - takes time and effort.
  • 14. Worth it Ask a Salary Increase and own a second modest vacation property
  • 15. And as an added bonus ● Better code architecture ● More functional code ● High browser compatibility ● No more regressions ● Neat cool stuff to brag about at your local pub!!!
  • 16. Setting it up client side
  • 17. Selenium IDE Firefox Plugin: http://release.seleniumhq.org/selenium-ide/1.10.0/selenium-ide-1.10.0.xpi ● Easy record and playback ● Intelligent field selection will use IDs, names, or XPath as needed ● Autocomplete for all common Selenium commands ● Walk through tests ● Debug and set breakpoints ● Save tests as HTML, PHPUnit, or any other format ● Support for Selenium user-extensions.js file ● Option to automatically assert the title of every page ● Easy customization through plugins
  • 20. X-forwarding run software on remote machine and display the GUI locally ● Linux and Mac OS X support X Forwarding with no extra software ssh -X ● Windows needs extra software Xming
  • 21. Xming (X-forwarding for windows) http://sourceforge.net/projects/xming/files/latest/download Configure Xming Windows Start => Xming => XLaunch Display settings dialog box: Multiple windows Display number as 0 Keep clicking next then Finish.
  • 22. Putty (windows) ● Connection => SSH => X11 ● Enable X11 forwarding ● Set X display location as :0.0
  • 23. Setting it up server side (headless)
  • 24. Firefox ● [64 bit] wget http://download-origin.cdn.mozilla.net/pub/mozilla.org/firefox/relea ● [32 bit] wget http://download-origin.cdn.mozilla.net/pub/mozilla.org/firefox/relea ● tar -jxvf firefox-18.0.tar.bz2 -C /opt ● ln -s /opt/firefox/firefox /usr/bin/firefox ● Firefox (No X-Display needed thanks to forwarding)
  • 25. Completely headless (no X-forwarding) ● Install Xvfb aptitude install Xvfb ● Update to latest java version aptitude install sun-java6-jre ● Download the latest Selenium Server Jar package wget http://selenium.googlecode.com/files/selenium- server-standalone-2.28.0.jar
  • 26. Test driving Selenium RC (X-forwarding) To test-drive it is always easier to first use X-forwarding: java -jar selenium-server-standalone-2.28.0.jar -htmlSuite *firefox "http://www.domaintocheck.com" “/path/to/selenium/testSuite.html” “/path/where/selenium/should/store/results.html” testSuite.html and related files are the files saved by Selenium IDE
  • 27. Test driving Selenium RC (X Virtual Frame Buffer) ● Open a connection and run Xvfb Xvfb :99 ● Open another connection and run selenium export DISPLAY=:99 & java -jar selenium-server- standalone-2.28.0.jar -htmlSuite *firefox "http://www.domaintocheck.com" “/path/to/selenium/testSuite.html” “/path/where/selenium/should/store/results.html”
  • 28. Integrate into Make certain your Jenkins server is started with Xvfb run on :99 ● Check with: ps -ef | grep Xvfb ● If not running then issue a Xvfb :99 CTRL + Z ● Log into Jenkins: manage Jenkins -> Manage Plugins install “Hudson Seleniumhq plugin”
  • 29. Setup a Job ● Create a new freestyle job
  • 30.
  • 31.
  • 32. Problem ● remote control is slow at driving the browser. ● limited number of concurrent tests on the same remote control before seriously impacting its stability. ● Multiple Selenium Remote Controls In Jenkins to work around the limitation on the number of parallel tests.
  • 33. The Grid ● Run tests against multiple browsers ● multiple versions of browser ● browsers running on different operating systems ● To reduce the time it takes for the test suite to complete a test pass.
  • 34.
  • 35. The Hub ● 1 instance ● Allocating a Selenium Remote Control to a specific test (transparently) ● Limiting the number of concurrent test runs on each Remote Control ● Shielding the tests from the actual grid infrastructure
  • 36. A Node ● Remote Control ● Multiple instances (across machines preferably) ● Multiple Browsers ● Can be configured using a json file
  • 38. Start the hub java -jar selenium-server-standalone-2.28.0.jar -role hub ● Start nodes on separate machines java -jar selenium-server-standalone-2.28.0.jar -role node -hub http://hub-address:4444/grid/register
  • 40. Optimizing a Node with js ● java -jar selenium-server-standalone-2.28.0.jar -role node -nodeConfig nodeConfig.js //nodeConfig.js { "class":"org.openqa.grid.common.RegistrationRequest", "capabilities":[ { "platform":"VISTA", "seleniumProtocol":"Selenium", "browserName":"*firefox", "maxInstances":5 }, { "platform":"VISTA", "seleniumProtocol":"Selenium", "browserName":"*iexplore", "maxInstances":1 } ],
  • 41. "configuration":{ "port":5555, "register":true, "host":"node-address", "proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "maxSession":5, "role":"node", "hubHost":"hub-address", "registerCycle":5000, "hub":"http://hub-address:4444/grid/register", "hubPort":4444, "url":"http://node-address:5555", "remoteHost":"http://node-address:5555" } }
  • 43. Run the suite ● No Native HTML Selenese tests support ● Web driver needed ● PHPUnit
  • 44. + Selenium Web Driver wget http://pear.phpunit.de/get/phpunit.phar chmod +x phpunit.phar
  • 45. Selenium-ide-php-formatters Convert Html Selenese tests to PHPUnit test cases Firefox Addon: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide- php-formatters/
  • 47. The test case <?php class Example extends PHPUnit_Extensions_SeleniumTestCase { protected function setUp() { $this->setBrowser("*iexplore"); $this->setBrowserUrl("http://www.nickbelhomme.com/"); } public function testMyTestCase() { $this->open("/"); $this->assertTrue($this->isElementPresent("link=About")); $this->assertTrue($this->isElementPresent("link=Consulting & Training")); $this->assertTrue($this->isElementPresent("link=Blog")); $this->assertTrue($this->isElementPresent("link=Contact")); $name = $this->getEval(""nick"==="nick""); } } ?>
  • 48. Run the test case php phpunit.phar testcases/testMenu.php Run the test suite php phpunit.phar testcases
  • 49. Use multiple browsers public static $browsers = array( array( 'name' => 'Firefox', 'browser' => '*firefox', 'host' => 'hub-address', 'port' => 4444, 'timeout' => 30000, ), array( 'name' => 'Internet Explorer', 'browser' => '*iexplore', 'host' => 'hub-address', 'port' => 4444, 'timeout' => 30000, ) ); protected function setUp() { $this->setBrowserUrl('http://www.example.com/'); }
  • 50. Use raw Html Selenese test public function testMenu() { $this->runSelenese('testMenu.html') } Use raw Html Selenese testsuite public static $seleneseDirectory = '/path/to/files';
  • 52. With Paratest Parallel PHPUnit – running tests concurrently ● Support for annotated tests ● Inheritance ● Tests suites ● Test methods ● Reflection driven
  • 53. composer install // composer.json { "require": { "brianium/paratest": "dev-master", "phpunit/dbunit": ">=1.2", "phpunit/php-invoker": "*", "phpunit/phpunit-selenium": ">=1.2", "phpunit/phpunit-story": "*" } }
  • 55. References ● X-Forwarding: http://en.gentoo-wiki.com/wiki/X-Forwarding http://www.straightrunning.com/XmingNotes/ ● Xvfb http://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml ● Driving Selenium with PHPUnit http://www.phpunit.de/manual/3.8/en/selenium.html ● Selenium Hq http://seleniumhq.org/docs/index.jsp ● Composer http://getcomposer.org ● Paratest http://brianscaturro.com/2012/11/02/parallel-phpunit.html
  • 56. Troubleshooting ● Firefox install dependencies http://www.thinkplexx.com/learn/howto/linux/system/installing- and-running-firefox-on-debian-linux-getting-missing- dependencies-shared-libs ● Specify different ports in Jenkins for each RC when not using the grid ● Proxy settings in Browser – use X-Forwarding to run Browser and change settings, use profile as a RC param when needed.
  • 57. Link to slides and other updates is available at http://www.facebook.com/NickBelhommeFanPage
  • 58. The End! THANK YOU Please rate my talk https://joind.in/7796 contact@nickbelhomme.com Slideshare, Twitter, IRC: NickBelhomme http://blog.nickbelhomme.com
  • 59. Flickr Photo Credits Backgrounds by Flikr http://www.flickr.com/photos/flikr/146538982/ http://www.flickr.com/photos/flikr/147274362/

Editor's Notes

  1. System: tests request, router, controller, view, response Black box: you do not have to be aware of the code behind the system. And thus you do not write your tests accordingly Functional: tests complete gui and behavior
  2. System: tests request, router, controller, view, response Black box: you do not have to be aware of the code behind the system. And thus you do not write your tests accordingly Functional: tests complete gui and behavior
  3. System: tests request, router, controller, view, response Black box: you do not have to be aware of the code behind the system. And thus you do not write your tests accordingly Functional: tests complete gui and behavior