AUTOMATED SYSTEM
TESTS FOR JOOMLA
Puneet Kala
OUTLINE
 What is System Testing?
 How is automation testing used in Joomla?
 How do I set up my PC to run system tests?...
SOME BASIC QUESTION
 What is Automated testing?
 Running programs to test other programs
 What is PHPunit?
 A library ...
AUTOMATED TESTING IN JOOMLA
 Webdriver Tests was started in Nov, 2012, by
Mark Dexter
 Backend CMS tests along with Sele...
DEVELOPER’S NIGHTMARE
HOW TO AVOID?
WHY DO WE NEED AUTOMATION
TESTING
 Helps in preventing software release with
obvious bugs
 Allows you to integrate conti...
ALTERNATIVE TO AUTOMATION
TESTING
SYSTEM TESTING
 Test at the user level from outside the program
 Testing a process for example: testing user
creations, ...
SETUP TO RUN SYSTEM TESTS
 PHPUnit 3.6 or higher (latest is 4.1) Use PHAR
to install.
 PHP 5.3.8 (required for Webdriver...
SETUP TO RUN SYSTEM TESTS-2
 Download Selenium Server (Java ".jar") from
seleniumhq.com
 run in background
 Checkout Jo...
FILE STRUCTURE
EXECUTE SYSTEM TESTS
 Run Selenium Server in the background
 do once and let it run
 Change to desired folder
 Webdriv...
TEST CONFIGURATION
 phpunit.xml.dist / phpunit.xml
 .dist is included in Git, .xml is local only
 configdef.php.dist is...
LETS LOOK AT A DEMO
 Installation Tests
 Tag Manager Tests
SELENIUM WEBDRIVER VS
SELENIUM IDE
 IDE is a record and playback tool, which is not
reliable as compared to Selenium Webd...
ANATOMY OF WEBDRIVER TEST
CLASS
PAGE OBJECT DESIGN PATTERN
PAGE CLASSES
 Classes that contains specific details about the
Joomla page
 $waitForXpath: identifies this page
 $url: ...
TEST DETAIL
ACTIONS
 We can perform several actions such as:
 Click, sendKeys, Select etc.
 We can not perform certain actions such...
VERFICATION
 We perform several assertions based on our
actions
 Did the right page load?
 Did we get the expected mess...
WEBDRIVER FOR PHP
 Requires third-party library
 Using Nearsoft library
 https://github.com/Nearsoft/PHP-SeleniumClient...
WEBDRIVER CLASS
 Provided by third party library for PHP
 PHP implementations based on Java
 Found in
tests/system/webd...
WEBDRIVER KEY METHODS
 get($url) – loads URL
 findElement(By::<>) – returns a WebElement
 xPath, id, name, className, c...
WEB ELEMENTS KEY METHODS
 sendKeys(): types into element
 getText(): returns element text
 getTagName: returns tag name...
LOCATOR STRATEGIES
LOCATORS
 Good Locators are:
 Unique
 Descriptive
 Unlikely to change
 CSS and Xpaths are mostly used selectors in au...
XPATHS
 Most powerful option for finding elements
 Used in findElement(By::xPath(“XPATH of
Element”)) method of webdrive...
PHPUNIT ASSERT STATMENTS
 Assertions are expression which verify testing
logic and make sure that application behaves in
...
SCALING SYSTEM TEST
 Use cloud-based testing services
 Parallelize tests to run multiple test classes at
once
 Using Se...
SAUCE-LABS
SAUCE LABS
 Sauce On Demand is a cloud-based service that
allows you to run automated cross-browser
functional tests at h...
INTEGRATING SAUCE WITH
JOOMLA SYSTEM TESTS
 Setup Sauce Library
 Get Sauce Connect
 Change desired capabilities accordi...
THANKS!
 Email ID:puneet.0191@gmail.com
 Twitter: puneet_kala
 Skype: puneet.0191
INEVITABLE
Upcoming SlideShare
Loading in …5
×

Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!

2,259 views

Published on

Presentation from JAB-2014, I have talked about how we have setup PHPUnit and Selenium Webdriver for Testing Joomla CMS!,

How we can setup System test Suite for a Joomla! Component

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

No Downloads
Views
Total views
2,259
On SlideShare
0
From Embeds
0
Number of Embeds
78
Actions
Shares
0
Downloads
15
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • You release a new version and someone finds a really obvious bug (most likely due to a stupid, last-minute coding error).
  • Stop releasing new versions??
    More Testing before each release
    Continuous testing during development
    Test daily after each change to the code base
  • Parent class for all test classes
    Extends PHPUnit_Framework_TestCase (PHPUnitEclass)
    Uses bootstrap.php to autoload, configdef.php to get SeleniumConfig class
    Holds methods needed by all test classes
    doAdminLogin(), doAdminLogout()
  • Problem: For an application that is under continuous development, web pages can change any time
    New Elements introduced
    Change in links, change in buttons
    Changes in the way the page looks
    Any change in the application should require changes in the page classes not in the actual test
    Logic for interacting with the application is written in Test Class but functions to perform that logic are present in the Page Classes
  • Good Locators are:
    Unique
    Descriptive
    Unlikely to change
    CSS and Xpaths are mostly used selectors in automation testing, ex.
    Xpath Selector: //div[@id=&amp;apos;example&amp;apos;]//a
    Css Selector: css=div.example a
    Performance of them varies with different browsers, for more details about CSS Vs Xpath please see here: http://elementalselenium.com/tips/category/benchmarks
    ‘ID’ selectors is the fastest method, but for that we need to have id attributes for all the test fields
  • Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!

    1. 1. AUTOMATED SYSTEM TESTS FOR JOOMLA Puneet Kala
    2. 2. OUTLINE  What is System Testing?  How is automation testing used in Joomla?  How do I set up my PC to run system tests?  How do I write system tests for my extension?
    3. 3. SOME BASIC QUESTION  What is Automated testing?  Running programs to test other programs  What is PHPunit?  A library used for creating PHP unit tests  What is Selenium?  A program which is used for creating System Tests, Automating browsers  What is Xpath?  A syntax for navigating elements in a web page
    4. 4. AUTOMATED TESTING IN JOOMLA  Webdriver Tests was started in Nov, 2012, by Mark Dexter  Backend CMS tests along with Selenium Webdriver were developed as part of GSOC,2013.  Frontend CMS Tests are being developed as part of GSOC, 2014.
    5. 5. DEVELOPER’S NIGHTMARE
    6. 6. HOW TO AVOID?
    7. 7. WHY DO WE NEED AUTOMATION TESTING  Helps in preventing software release with obvious bugs  Allows you to integrate continuous testing into your development process  Saves a lot of time  Reliable  Cost reduction
    8. 8. ALTERNATIVE TO AUTOMATION TESTING
    9. 9. SYSTEM TESTING  Test at the user level from outside the program  Testing a process for example: testing user creations, testing Tag creations  Running the application and testing it just like a user would do.
    10. 10. SETUP TO RUN SYSTEM TESTS  PHPUnit 3.6 or higher (latest is 4.1) Use PHAR to install.  PHP 5.3.8 (required for Webdriver system tests)  Curl package (extension=php_curl.dll or php_curl.so in php.ini)
    11. 11. SETUP TO RUN SYSTEM TESTS-2  Download Selenium Server (Java ".jar") from seleniumhq.com  run in background  Checkout Joomla from Github.com  Create configdef.php file (tests/system/servers)  used for old and new tests
    12. 12. FILE STRUCTURE
    13. 13. EXECUTE SYSTEM TESTS  Run Selenium Server in the background  do once and let it run  Change to desired folder  Webdriver System: tests/system/webdriver/tests  phpunit <optional name of sub-folder or file>
    14. 14. TEST CONFIGURATION  phpunit.xml.dist / phpunit.xml  .dist is included in Git, .xml is local only  configdef.php.dist is generic  need to create configdef.php file with local values
    15. 15. LETS LOOK AT A DEMO  Installation Tests  Tag Manager Tests
    16. 16. SELENIUM WEBDRIVER VS SELENIUM IDE  IDE is a record and playback tool, which is not reliable as compared to Selenium Webdriver.  Selenium IDE tests require huge amount of Maintenance  Webdriver has a Object Oriented API  It is difficult to use Selenium IDE for checking complex test cases involving dynamic contents  No Programming logic (like loops, conditional statements) can be applied in Selenium IDE.
    17. 17. ANATOMY OF WEBDRIVER TEST CLASS
    18. 18. PAGE OBJECT DESIGN PATTERN
    19. 19. PAGE CLASSES  Classes that contains specific details about the Joomla page  $waitForXpath: identifies this page  $url: URL for the page  Elements: toolbar, input elements, menu elements  Methods specific to the page:  For example: TagManagerPage would contain functions like createTag(), editTag(), deleteTag(), searchTag()  Page classes do not perform any assertions, it is the job of test class to perform assertions.  Re-Usable/Maintainable code
    20. 20. TEST DETAIL
    21. 21. ACTIONS  We can perform several actions such as:  Click, sendKeys, Select etc.  We can not perform certain actions such as:  Changing Value of a Hidden Field.  Element must be present in the view to access.
    22. 22. VERFICATION  We perform several assertions based on our actions  Did the right page load?  Did we get the expected message?  Was the item created?  Was the state of a item changed?  Was the item deleted?  Can we search for the item?  Are all the expected elements present on the page?
    23. 23. WEBDRIVER FOR PHP  Requires third-party library  Using Nearsoft library  https://github.com/Nearsoft/PHP-SeleniumClient  Located in folder tests/system/webdriver/SeleniumClient  Provides the "magic" for interacting with the page
    24. 24. WEBDRIVER CLASS  Provided by third party library for PHP  PHP implementations based on Java  Found in tests/system/webdriver/SeleniumClient/WebDriv er.php
    25. 25. WEBDRIVER KEY METHODS  get($url) – loads URL  findElement(By::<>) – returns a WebElement  xPath, id, name, className, cssSelector, linkText, partialLinkText, tagName  findElements(By::<>)  returns array of WebElements (can be zero)  executeScript() – executes JavaScript  for example, move mouse to location
    26. 26. WEB ELEMENTS KEY METHODS  sendKeys(): types into element  getText(): returns element text  getTagName: returns tag name  getAttribute: returns value of attribute  clear(): clears text  click(): clicks  submit(): submits form
    27. 27. LOCATOR STRATEGIES
    28. 28. LOCATORS  Good Locators are:  Unique  Descriptive  Unlikely to change  CSS and Xpaths are mostly used selectors in automation testing, ex.  Xpath Selector: //div[@id='example']//a  Css Selector: css=div.example a  Performance of them varies with different browsers, for more details about CSS Vs Xpath please see here: http://elementalselenium.com/tips/category/benchmarks  ‘ID’ selectors is the fastest method, but for that we need to have id attributes for all the test fields
    29. 29. XPATHS  Most powerful option for finding elements  Used in findElement(By::xPath(“XPATH of Element”)) method of webdriver.  Slower than CSS selectors on most of the browsers but reliable, and easy to maintain.
    30. 30. PHPUNIT ASSERT STATMENTS  Assertions are expression which verify testing logic and make sure that application behaves in expected way. ex. assertTrue, assertFalse, assertEquals
    31. 31. SCALING SYSTEM TEST  Use cloud-based testing services  Parallelize tests to run multiple test classes at once  Using Selenium Grid to Parallelize Tests
    32. 32. SAUCE-LABS
    33. 33. SAUCE LABS  Sauce On Demand is a cloud-based service that allows you to run automated cross-browser functional tests at high speeds in parallel, so you don't need to maintain testing infrastructure.  Sauce Support 65+browser and OS combination .  Operating Systems like Windows, Linux, Mac ,  Browsers like Internet Explorer, Chrome, Firefox, Safari, Opera, IPhone, Ipad, Android  All latest browsers versions are available.
    34. 34. INTEGRATING SAUCE WITH JOOMLA SYSTEM TESTS  Setup Sauce Library  Get Sauce Connect  Change desired capabilities according to Sauce Configuration  Change Host name and port No. for webdriver connection  Demo
    35. 35. THANKS!  Email ID:puneet.0191@gmail.com  Twitter: puneet_kala  Skype: puneet.0191
    36. 36. INEVITABLE

    ×