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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Selenium 2 for PHP(Unit)

1,922
views

Published on

May 23, 2012

May 23, 2012

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,922
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Fabrizio BrancaT3DD12Selenium 2for PHP(Unit)
  • 2. System DeveloperAOE mediaWiesbadenTYPO3 & MagentoTwitter: @fbrncBlog: http://www.fabrizio-branca.deFabrizio Branca
  • 3. • Who has any experience with automatedtesting? (PHPUnit,…)• Who has used Selenium 1?• Who has used Selenium 2 / Webdriver?You?!
  • 4. http://www.flickr.com/photos/dieselbug2007/414348333/
  • 5. • Unit testing• Performance testing• Load testing• Integration testing• Acceptance testingTesting
  • 6. What is Selenium?
  • 7. • Selenium IDE• Selenium 1(aka. Selenium RC or Remote Control)• Selenium 2(aka. Selenium Webdriver)• Selenium-GridSelenium’s Tool Suite
  • 8. Selenium Architecture
  • 9. Selenium + WebDriver2004:Selenium(Jason Huggins,ThoughtWorks)2006:WebDriver(Simon Stewart,Google)2009:Selenium 2
  • 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. • Firefox• HTMLUnit• IE• Chrome (needs extra driver)• iPhone / iPad• Android• …Selenium 2
  • 12. • Download:http://seleniumhq.org/download/• Launch:start java -jar C:ProgrammeSeleniumselenium-server-standalone-2.20.0.jarSelenium Server
  • 13. • http://code.google.com/p/selenium/wiki/JsonWireProtocol• Json over HTTPRest API
  • 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. • „A very thin wrapper of WebDriver“• Server API (Json over HTTP)php-webdriver
  • 16. „Menta“ – Selenium Framework
  • 17. Why „Menta“?
  • 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. • 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. • 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. • PHPUnit• default.xml + phpunit.xml• Menta bootstrap.phpConfiguration
  • 22. File structure
  • 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. • $element->click();• $this->getSession()->click();• $this->getSession()->buttondown();• $this->getSession()->buttonup();• $this->getSession()->touch();• $this->getSession()->moveto();Interacting with elements
  • 25. • Capabilities• Menta_SessionManager• ->getSession($forceNew = false);• ->activeSessionExists()• ->closeSession()• Automatic closing sessions on errors andend of testsSession Management
  • 26. • Implicitly waiting for elements that are notavailable yetImplicit Wait
  • 27. • Explict screenshots• Automatically taking screenshots on errorsand failing tests and embed them into htmlreport (on client side)Screenshots
  • 28. Demo
  • 29. CI integrationBuildpackageUnit testsInstall onlatestSeleniumtestsInstall ondeployQALoadtestsInstall onstageInstall onproduction
  • 30. Verbose Result Printer
  • 31. HTML Result
  • 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. Questions?Twitter: @fbrncBlog: http://www.fabrizio-branca.de

×