Selenium 2 for PHP(Unit)
Upcoming SlideShare
Loading in...5

Selenium 2 for PHP(Unit)






Total Views
Views on SlideShare
Embed Views



1 Embed 3 3


Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Selenium 2 for PHP(Unit) Selenium 2 for PHP(Unit) Presentation Transcript

  • Selenium 2for PHP(Unit) Fabrizio Branca T3DD12
  • Fabrizio BrancaSystem DeveloperAOE mediaWiesbadenTYPO3 & MagentoTwitter: @fbrncBlog:
  • You?!• Who has any experience with automated testing? (PHPUnit,…)• Who has used Selenium 1?• Who has used Selenium 2 / Webdriver?
  • Testing• Unit testing• Performance testing• Load testing• Integration testing• Acceptance testing
  • What is Selenium?
  • Selenium’s Tool Suite• Selenium IDE• Selenium 1 (aka. Selenium RC or Remote Control)• Selenium 2 (aka. Selenium Webdriver)• Selenium-Grid
  • Selenium Architecture
  • Selenium + WebDriver 2004: 2006: Selenium WebDriver (Jason Huggins, (Simon Stewart, ThoughtWorks) Google) 2009: Selenium 2
  • Why Selenium 2?• New possibilities – File uploads – Browser functions (back/forward) – Switch between urls – Control mouse• Different behaviour – Typing into input boxes – Interacting with invisible elements – Viewport
  • Selenium 2• Firefox• HTMLUnit• IE• Chrome (needs extra driver)• iPhone / iPad• Android• …
  • Selenium Server• Download:• Launch: start java -jar C:ProgrammeSeleniumselenium-server-standalone-2.20.0.jar
  • Rest API• onWireProtocol• Json over HTTP
  • PHP Api• Selenium 1: PHPUnit_Selenium (Sebastian Bergmann)• Selenium 2 – REST-Service (Json over HTTP) – Implementations: • PHPUnit_Selenium • • •
  • php-webdriver• „A very thin wrapper of WebDriver“• Server API (Json over HTTP)
  • „Menta“ – Selenium Framework
  • Why „Menta“?
  • Menta• Selenium Testing Framework• Connects to Selenium 2• Build on top of php-webdriver• Developer friendly api to raw Selenium commands• Drop-In replacement for PHPUnit- Selenium•
  • Menta• Requires PHP 5.3 (using closures)• Session management (incl. close on CTRL+C and fatal php errors)• Event/Observer• Configuration Management• Create Suite Utility• Listeners – HTML report (incl. Screenshots) – Verbose text report• Components• Abstract PHPUnit Testcases• Selenium1 facade
  • Components• PageObjects• selenium-tests.html• Other general purpose components – WebServiceApi (Magento) – Curl – HTML/CSS/JS Validator – Imap
  • Configuration• PHPUnit• default.xml + phpunit.xml• Menta bootstrap.php
  • File structure
  • Selecting elements$element = $this->getSession()->element(array( using => WebDriver_Container::XPATH, value => //ul/li);# ... or ...$helper = Menta_ComponentManager::get( Menta_Component_Helper_Common);$element = $helper->getElement(css=#menu li.first);
  • Interacting with elements• $element->click();• $this->getSession()->click();• $this->getSession()->buttondown();• $this->getSession()->buttonup();• $this->getSession()->touch();• $this->getSession()->moveto();
  • Session Management• Capabilities• Menta_SessionManager• ->getSession($forceNew = false);• ->activeSessionExists()• ->closeSession()• Automatic closing sessions on errors and end of tests
  • Implicit Wait• Implicitly waiting for elements that are not available yet
  • Screenshots• Explict screenshots• Automatically taking screenshots on errors and failing tests and embed them into html report (on client side)
  • Demo
  • CI integration Build Install on Unit tests package latest Selenium Install on QA tests deploy Load Install on Install on tests stage production
  • Verbose Result Printer
  • HTML Result
  • Further reading••• php-code• http://rostislav- selenium-2-on-webdriver-part.html
  • Questions?Twitter: @fbrncBlog: