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

Selenium 2 for PHP(Unit)

on

  • 10,603 views

 

Statistics

Views

Total Views
10,603
Views on SlideShare
10,600
Embed Views
3

Actions

Likes
5
Downloads
80
Comments
0

1 Embed 3

http://www.scoop.it 3

Accessibility

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.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
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: http://www.fabrizio-branca.de
  • You?!• Who has any experience with automated testing? (PHPUnit,…)• Who has used Selenium 1?• Who has used Selenium 2 / Webdriver?
  • http://www.flickr.com/photos/dieselbug2007/414348333/
  • 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: http://seleniumhq.org/download/• Launch: start java -jar C:ProgrammeSeleniumselenium-server-standalone-2.20.0.jar
  • Rest API• http://code.google.com/p/selenium/wiki/Js onWireProtocol• Json over HTTP
  • PHP Api• Selenium 1: PHPUnit_Selenium (Sebastian Bergmann)• Selenium 2 – REST-Service (Json over HTTP) – Implementations: • PHPUnit_Selenium • https://github.com/chibimagic/WebDriver-PHP/ • http://code.google.com/p/php-webdriver-bindings/ • https://github.com/facebook/php-webdriver https://github.com/robocoder/php-webdriver https://github.com/fbrnc/php-webdriver
  • 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• https://github.com/fbrnc/Menta
  • 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• http://www.typo3-media.com/blog/window-driver-page-object- 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• http://www.qaautomation.net/?p=365• http://www.qaautomation.net/?p=498• http://css.dzone.com/articles/selenium-2- php-code• http://rostislav- matl.blogspot.de/2011/03/moving-to- selenium-2-on-webdriver-part.html
  • Questions?Twitter: @fbrncBlog: http://www.fabrizio-branca.de