Uploaded on

Gems of Selenium

Gems of Selenium

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,693
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
48
Comments
0
Likes
1

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. Gems of Selenium Anand Ramdeo Komal Joshi @testinggeek www.TestingGeek.com
  • 2. Selenium Is.. www.atlantissw.com | www.TestingGeek.com
  • 3. A bit of History.. www.atlantissw.com | www.TestingGeek.com SELENIUM
  • 4. It All Started Here
    • Time and Expense application built using Python+Plone @ Thoughtworks
    • Goal was “Fast, Fast, Fast”
    www.atlantissw.com | www.TestingGeek.com ADD ROW
  • 5. It All Started Here
    • Time and Expense application built using Python+Plone @ Thoughtworks
    • Goal was “Fast, Fast, Fast”
    www.atlantissw.com | www.TestingGeek.com ADD ROW
  • 6. It All Started Here
    • Time and Expense application built using Python+Plone @ Thoughtworks
    • Goal was “Fast, Fast, Fast”
    www.atlantissw.com | www.TestingGeek.com ADD ROW
  • 7. Problems.. www.atlantissw.com | www.TestingGeek.com
  • 8. And Solutions..
    • Mozilla Extension – “Driftwood” by Andrew McCormick from Thoughtworks. Worked, but it was firefox only solution.
    • Paul Gross and Jasson Huggin set out to implement Fit for JS.
    • Which eventually became Selenium Core or Java Script Test Runner
    www.atlantissw.com | www.TestingGeek.com
  • 9. Popularity of Selenium www.atlantissw.com | www.TestingGeek.com
  • 10. Reason of Success www.atlantissw.com | www.TestingGeek.com
  • 11. In search of treasure @testinggeek www.TestingGeek.com
    • The journey begins..
    • Want to automate ?
    • What are the common problems faced by people when using selenium IDE?
  • 12. In search of treasure @testinggeek www.TestingGeek.com
    • Treasure is ….
    • Reliable automation.
    • Stable automation.
    • Maintainable automation.
    • Effective Automation .
  • 13. @testinggeek www.TestingGeek.com Found my first Gem…. UI Element  How can this precious gem help me?
  • 14. UI Element is... @testinggeek www.TestingGeek.com
    • ...a mapping between semantically meaningful names of elements on webpages, and the elements.
    • ...defined using JSON
  • 15. Abstraction With UI-Element
    • selenium.type("q", “TestingGeek");
    • selenium.click("btnG");
    @testinggeek www.TestingGeek.com LOGIN_BUTTON = "css=input[value='Log in']" DELETE_CONFIRMATION = "css=input[value='"Yes, I'm sure"']" myMap.addPageset({     name: 'allPages',     description: 'All WLL Pages',     pathRegexp: '.*' }); myMap.addElement ('allPages', {     name: 'register'     , description: 'Register link on all the pages'     , locator: "xpath=//*[@id='user']/dd/a[1]"    }) sel.click("ui=allPages::register()") Abstracting with UI Element
  • 16. @testinggeek www.TestingGeek.com I want to extend Selenium with some new assertions,actions No problem User-extension.js is here for that.
  • 17. Extending Slenium...
    • Selenium Object Prototype
    • Pagebot Object Prototype.
    • On startup, Selenium will automatically look through methods on these prototypes, using name patterns to recognize which ones are actions, assertions and locators.
    @testinggeek www.TestingGeek.com
  • 18. Automation is incomplete without cross browser testing
    • Selenium RC gem for different browser…
    • * iehta
    • * firefox
    • * iexplore
    • * chrome
    • * custom (for custom browsers)
    @testinggeek www.TestingGeek.com
  • 19. https...
    • Different options of selenium…
    • https
    • Multiwindow=<true/false>
    • Firefoxtemplate=<default template location>
    @testinggeek www.TestingGeek.com
  • 20. Collecting all the gems and putting in the treasure chest @testinggeek www.TestingGeek.com
  • 21. Is this the only treasure
    • The real gems are in your minds in your brains.
    • Come up with a solution
    • Implement a simple but effective solution.
    @testinggeek www.TestingGeek.com
  • 22. Automate using wrappers. @testinggeek www.TestingGeek.com SA
    • Use a combination of tools....
    • Selenium + Auto it.
    • Selenium + Batch files.
  • 23. @testinggeek www.TestingGeek.com SA /** * This method would just kill the PDF */ public void closesPDF(){ { String[] dialog = new String[] { &quot;srcestesourcesillAcroRd32.bat&quot;}; try { Process p = Runtime.getRuntime().exec(dialog); System.out.println(p.getErrorStream().toString()); System.out.println(p.getInputStream().toString()); System.out.println(p.getOutputStream().toString()); System.out.println(&quot;After execution&quot;); } catch (IOException e) { // TODO Auto-generated catch block System.out.println(&quot;In the exception&quot;); e.printStackTrace(); throw new AssertionError(&quot;No Dialogue box displayed&quot;); } } }
  • 24. Easy to read Natural language automation
    • Simple easy to read language
    • POM.
    @testinggeek www.TestingGeek.com
  • 25. Componentise your automation @testinggeek www.TestingGeek.com
  • 26. Add dynamism...
    • Connecting to the databses…
    @testinggeek www.TestingGeek.com
  • 27. @testinggeek www.TestingGeek.com All this is less effective if automation does not run automatically......
  • 28. Integrate with CI tools @testinggeek www.TestingGeek.com Mavenise your automation... And integrate them with Hudson...
  • 29. Distribute the Tests @testinggeek www.TestingGeek.com With Selenium Grids or Hudson Slaves...
  • 30. Integrate with CI tools @testinggeek www.TestingGeek.com What about Selenium 2.0 ?..... Will my old selenium tests run in 2.0?
  • 31. Selenium 2.0 @testinggeek www.TestingGeek.com -Web Driver - Presentation redering etc.
  • 32. @testinggeek www.TestingGeek.com import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.RenderedWebElement; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class TestingGeek { public static void main(String[] args) throws Exception { // The Firefox driver supports javascript WebDriver driver = new FirefoxDriver(); // Go to the TestingGeek home page driver.get(&quot;http://www.testinggeek.com&quot;); // Enter the query string &quot;Cheese&quot; //WebElement query = driver.findElement(By.name(&quot;q&quot;)); WebElement menu= driver.findElement(By. id(&quot;menu27&quot;)); menu.click(); // query.sendKeys(&quot;Cheese&quot;); // Sleep until the div we want is visible or 5 seconds is over long end = System. currentTimeMillis() + 5000; while (System. currentTimeMillis() < end) { // Browsers which render content (such as Firefox and IE) // return &quot;RenderedWebElements&quot; // RenderedWebElement resultsDiv = (RenderedWebElement) driver.findElement(By.className(&quot;gac_m&quot;)); RenderedWebElement resultsDiv = (RenderedWebElement) driver.findElement(By. id(&quot;menu27&quot;)); // If results have been returned, // the results are displayed in a drop down. if (resultsDiv.isDisplayed()) { break; } } // And now list the suggestions //List<WebElement> allSuggestions = driver.findElements(By. xpath(&quot;//td[@class='gac_c']&quot;)); List<WebElement> menus = driver.findElements(By. xpath(&quot;//div/div/div/ul/li[2]/ul&quot;)); for (WebElement menu1 : menus) { System. out.println(menu1.getText()); } } }
  • 33. Thank You.
    • Anand Ramdeo
    • www.TestingGeek.com
    • @testinggeek
    • www.AtlantisSw.com
    • [email_address]
    @testinggeek www.TestingGeek.com