0
Fabrizio BrancaT3DD12Selenium 2for PHP(Unit)
System DeveloperAOE mediaWiesbadenTYPO3 & MagentoTwitter: @fbrncBlog: http://www.fabrizio-branca.deFabrizio Branca
• Who has any experience with automatedtesting? (PHPUnit,…)• Who has used Selenium 1?• Who has used Selenium 2 / Webdriver...
http://www.flickr.com/photos/dieselbug2007/414348333/
• Unit testing• Performance testing• Load testing• Integration testing• Acceptance testingTesting
What is Selenium?
• Selenium IDE• Selenium 1(aka. Selenium RC or Remote Control)• Selenium 2(aka. Selenium Webdriver)• Selenium-GridSelenium...
Selenium Architecture
Selenium + WebDriver2004:Selenium(Jason Huggins,ThoughtWorks)2006:WebDriver(Simon Stewart,Google)2009:Selenium 2
• New possibilities– File uploads– Browser functions (back/forward)– Switch between urls– Control mouse• Different behavio...
• Firefox• HTMLUnit• IE• Chrome (needs extra driver)• iPhone / iPad• Android• …Selenium 2
• Download:http://seleniumhq.org/download/• Launch:start java -jar C:ProgrammeSeleniumselenium-server-standalone-2.20.0.ja...
• http://code.google.com/p/selenium/wiki/JsonWireProtocol• Json over HTTPRest API
• Selenium 1: PHPUnit_Selenium(Sebastian Bergmann)• Selenium 2– REST-Service (Json over HTTP)– Implementations:• PHPUnit_S...
• „A very thin wrapper of WebDriver“• Server API (Json over HTTP)php-webdriver
„Menta“ – Selenium Framework
Why „Menta“?
• Selenium Testing Framework• Connects to Selenium 2• Build on top of php-webdriver• Developer friendly api to raw Seleniu...
• Requires PHP 5.3 (using closures)• Session management (incl. close on CTRL+C andfatal php errors)• Event/Observer• Confi...
• PageObjects• http://www.typo3-media.com/blog/window-driver-page-object-selenium-tests.html• Other general purpose compon...
• PHPUnit• default.xml + phpunit.xml• Menta bootstrap.phpConfiguration
File structure
$element = $this->getSession()->element(array(using => WebDriver_Container::XPATH,value => //ul/li);# ... or ...$helper =M...
• $element->click();• $this->getSession()->click();• $this->getSession()->buttondown();• $this->getSession()->buttonup();•...
• Capabilities• Menta_SessionManager• ->getSession($forceNew = false);• ->activeSessionExists()• ->closeSession()• Automat...
• Implicitly waiting for elements that are notavailable yetImplicit Wait
• Explict screenshots• Automatically taking screenshots on errorsand failing tests and embed them into htmlreport (on clie...
Demo
CI integrationBuildpackageUnit testsInstall onlatestSeleniumtestsInstall ondeployQALoadtestsInstall onstageInstall onprodu...
Verbose Result Printer
HTML Result
• http://www.qaautomation.net/?p=365• http://www.qaautomation.net/?p=498• http://css.dzone.com/articles/selenium-2-php-cod...
Questions?Twitter: @fbrncBlog: http://www.fabrizio-branca.de
Upcoming SlideShare
Loading in...5
×

Selenium 2 for PHP(Unit)

2,014

Published on

May 23, 2012

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,014
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Selenium 2 for PHP(Unit)"

  1. 1. Fabrizio BrancaT3DD12Selenium 2for PHP(Unit)
  2. 2. System DeveloperAOE mediaWiesbadenTYPO3 & MagentoTwitter: @fbrncBlog: http://www.fabrizio-branca.deFabrizio Branca
  3. 3. • Who has any experience with automatedtesting? (PHPUnit,…)• Who has used Selenium 1?• Who has used Selenium 2 / Webdriver?You?!
  4. 4. http://www.flickr.com/photos/dieselbug2007/414348333/
  5. 5. • Unit testing• Performance testing• Load testing• Integration testing• Acceptance testingTesting
  6. 6. What is Selenium?
  7. 7. • Selenium IDE• Selenium 1(aka. Selenium RC or Remote Control)• Selenium 2(aka. Selenium Webdriver)• Selenium-GridSelenium’s Tool Suite
  8. 8. Selenium Architecture
  9. 9. Selenium + WebDriver2004:Selenium(Jason Huggins,ThoughtWorks)2006:WebDriver(Simon Stewart,Google)2009:Selenium 2
  10. 10. • New possibilities– File uploads– Browser functions (back/forward)– Switch between urls– Control mouse• Different behaviour– Typing into input boxes– Interacting with invisible elements– ViewportWhy Selenium 2?
  11. 11. • Firefox• HTMLUnit• IE• Chrome (needs extra driver)• iPhone / iPad• Android• …Selenium 2
  12. 12. • Download:http://seleniumhq.org/download/• Launch:start java -jar C:ProgrammeSeleniumselenium-server-standalone-2.20.0.jarSelenium Server
  13. 13. • http://code.google.com/p/selenium/wiki/JsonWireProtocol• Json over HTTPRest API
  14. 14. • 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-webdriverhttps://github.com/robocoder/php-webdriverhttps://github.com/fbrnc/php-webdriverPHP Api
  15. 15. • „A very thin wrapper of WebDriver“• Server API (Json over HTTP)php-webdriver
  16. 16. „Menta“ – Selenium Framework
  17. 17. Why „Menta“?
  18. 18. • Selenium Testing Framework• Connects to Selenium 2• Build on top of php-webdriver• Developer friendly api to raw Seleniumcommands• Drop-In replacement for PHPUnit-Selenium• https://github.com/fbrnc/MentaMenta
  19. 19. • Requires PHP 5.3 (using closures)• Session management (incl. close on CTRL+C andfatal php errors)• Event/Observer• Configuration Management• Create Suite Utility• Listeners– HTML report (incl. Screenshots)– Verbose text report• Components• Abstract PHPUnit Testcases• Selenium1 facadeMenta
  20. 20. • 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– ImapComponents
  21. 21. • PHPUnit• default.xml + phpunit.xml• Menta bootstrap.phpConfiguration
  22. 22. File structure
  23. 23. $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);Selecting elements
  24. 24. • $element->click();• $this->getSession()->click();• $this->getSession()->buttondown();• $this->getSession()->buttonup();• $this->getSession()->touch();• $this->getSession()->moveto();Interacting with elements
  25. 25. • Capabilities• Menta_SessionManager• ->getSession($forceNew = false);• ->activeSessionExists()• ->closeSession()• Automatic closing sessions on errors andend of testsSession Management
  26. 26. • Implicitly waiting for elements that are notavailable yetImplicit Wait
  27. 27. • Explict screenshots• Automatically taking screenshots on errorsand failing tests and embed them into htmlreport (on client side)Screenshots
  28. 28. Demo
  29. 29. CI integrationBuildpackageUnit testsInstall onlatestSeleniumtestsInstall ondeployQALoadtestsInstall onstageInstall onproduction
  30. 30. Verbose Result Printer
  31. 31. HTML Result
  32. 32. • 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.htmlFurther reading
  33. 33. Questions?Twitter: @fbrncBlog: http://www.fabrizio-branca.de
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×