0
Gems of Selenium Anand Ramdeo  Komal Joshi @testinggeek www.TestingGeek.com
Selenium Is.. www.atlantissw.com | www.TestingGeek.com
A bit of History.. www.atlantissw.com | www.TestingGeek.com SELENIUM
It All Started Here <ul><li>Time and Expense application built using Python+Plone @ Thoughtworks </li></ul><ul><li>Goal wa...
It All Started Here <ul><li>Time and Expense application built using Python+Plone @ Thoughtworks </li></ul><ul><li>Goal wa...
It All Started Here <ul><li>Time and Expense application built using Python+Plone @ Thoughtworks </li></ul><ul><li>Goal wa...
Problems.. www.atlantissw.com | www.TestingGeek.com
And Solutions.. <ul><li>Mozilla Extension – “Driftwood” by Andrew McCormick  from Thoughtworks. Worked, but it was firefox...
Popularity of Selenium www.atlantissw.com | www.TestingGeek.com
Reason of Success www.atlantissw.com | www.TestingGeek.com
In search of treasure @testinggeek www.TestingGeek.com <ul><li>The journey begins.. </li></ul><ul><li>Want to automate ?  ...
In search of treasure @testinggeek www.TestingGeek.com <ul><li>Treasure is …. </li></ul><ul><li>Reliable automation. </li>...
@testinggeek www.TestingGeek.com Found my first Gem…. UI Element   How can this precious gem help me?
UI Element is... @testinggeek www.TestingGeek.com <ul><li>...a mapping between semantically meaningful names of elements o...
Abstraction With UI-Element <ul><li>selenium.type(&quot;q&quot;, “TestingGeek&quot;); </li></ul><ul><li>selenium.click(&qu...
@testinggeek www.TestingGeek.com I want to extend Selenium with some new assertions,actions No problem User-extension.js i...
Extending Slenium... <ul><li>Selenium Object Prototype </li></ul><ul><li>Pagebot Object Prototype. </li></ul><ul><li>On st...
Automation is incomplete without cross browser testing <ul><li>Selenium RC gem for different browser… </li></ul><ul><li>* ...
https... <ul><li>Different options of selenium… </li></ul><ul><li>https </li></ul><ul><li>Multiwindow=<true/false> </li></...
Collecting all the gems and putting in the treasure chest @testinggeek www.TestingGeek.com
Is this the only treasure <ul><li>The real gems are in your minds in your brains. </li></ul><ul><li>Come up with a solutio...
Automate using wrappers. @testinggeek www.TestingGeek.com SA <ul><li>Use a combination of tools.... </li></ul><ul><li>Sele...
@testinggeek www.TestingGeek.com SA /** * This method would just kill the PDF */ public void closesPDF(){ { String[] dialo...
Easy to read Natural language automation <ul><li>Simple easy to read language </li></ul><ul><li>POM. </li></ul>@testinggee...
Componentise your automation @testinggeek www.TestingGeek.com
Add dynamism... <ul><li>Connecting to the databses… </li></ul>@testinggeek www.TestingGeek.com
@testinggeek www.TestingGeek.com All this is less effective if automation does not run automatically......
Integrate with CI tools @testinggeek www.TestingGeek.com Mavenise your automation... And  integrate them with Hudson...
Distribute the Tests  @testinggeek www.TestingGeek.com With Selenium Grids or Hudson Slaves...
Integrate with CI tools @testinggeek www.TestingGeek.com What about Selenium 2.0 ?..... Will my old selenium tests run in ...
Selenium 2.0 @testinggeek www.TestingGeek.com -Web Driver -  Presentation redering etc.
@testinggeek www.TestingGeek.com import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDrive...
Thank You. <ul><li>Anand Ramdeo </li></ul><ul><li>www.TestingGeek.com </li></ul><ul><li>@testinggeek </li></ul><ul><li>www...
Upcoming SlideShare
Loading in...5
×

Gems Of Selenium

2,739

Published on

Gems of Selenium

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

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

No notes for slide

Transcript of "Gems Of Selenium"

  1. 1. Gems of Selenium Anand Ramdeo Komal Joshi @testinggeek www.TestingGeek.com
  2. 2. Selenium Is.. www.atlantissw.com | www.TestingGeek.com
  3. 3. A bit of History.. www.atlantissw.com | www.TestingGeek.com SELENIUM
  4. 4. It All Started Here <ul><li>Time and Expense application built using Python+Plone @ Thoughtworks </li></ul><ul><li>Goal was “Fast, Fast, Fast” </li></ul>www.atlantissw.com | www.TestingGeek.com ADD ROW
  5. 5. It All Started Here <ul><li>Time and Expense application built using Python+Plone @ Thoughtworks </li></ul><ul><li>Goal was “Fast, Fast, Fast” </li></ul>www.atlantissw.com | www.TestingGeek.com ADD ROW
  6. 6. It All Started Here <ul><li>Time and Expense application built using Python+Plone @ Thoughtworks </li></ul><ul><li>Goal was “Fast, Fast, Fast” </li></ul>www.atlantissw.com | www.TestingGeek.com ADD ROW
  7. 7. Problems.. www.atlantissw.com | www.TestingGeek.com
  8. 8. And Solutions.. <ul><li>Mozilla Extension – “Driftwood” by Andrew McCormick from Thoughtworks. Worked, but it was firefox only solution. </li></ul><ul><li>Paul Gross and Jasson Huggin set out to implement Fit for JS. </li></ul><ul><li>Which eventually became Selenium Core or Java Script Test Runner </li></ul>www.atlantissw.com | www.TestingGeek.com
  9. 9. Popularity of Selenium www.atlantissw.com | www.TestingGeek.com
  10. 10. Reason of Success www.atlantissw.com | www.TestingGeek.com
  11. 11. In search of treasure @testinggeek www.TestingGeek.com <ul><li>The journey begins.. </li></ul><ul><li>Want to automate ? </li></ul><ul><li>What are the common problems faced by people when using selenium IDE? </li></ul>
  12. 12. In search of treasure @testinggeek www.TestingGeek.com <ul><li>Treasure is …. </li></ul><ul><li>Reliable automation. </li></ul><ul><li>Stable automation. </li></ul><ul><li>Maintainable automation. </li></ul><ul><li>Effective Automation . </li></ul>
  13. 13. @testinggeek www.TestingGeek.com Found my first Gem…. UI Element  How can this precious gem help me?
  14. 14. UI Element is... @testinggeek www.TestingGeek.com <ul><li>...a mapping between semantically meaningful names of elements on webpages, and the elements. </li></ul><ul><li>...defined using JSON </li></ul>
  15. 15. Abstraction With UI-Element <ul><li>selenium.type(&quot;q&quot;, “TestingGeek&quot;); </li></ul><ul><li>selenium.click(&quot;btnG&quot;); </li></ul>@testinggeek www.TestingGeek.com LOGIN_BUTTON = &quot;css=input[value='Log in']&quot; DELETE_CONFIRMATION = &quot;css=input[value='&quot;Yes, I'm sure&quot;']&quot; myMap.addPageset({     name: 'allPages',     description: 'All WLL Pages',     pathRegexp: '.*' }); myMap.addElement ('allPages', {     name: 'register'     , description: 'Register link on all the pages'     , locator: &quot;xpath=//*[@id='user']/dd/a[1]&quot;    }) sel.click(&quot;ui=allPages::register()&quot;) Abstracting with UI Element
  16. 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. 17. Extending Slenium... <ul><li>Selenium Object Prototype </li></ul><ul><li>Pagebot Object Prototype. </li></ul><ul><li>On startup, Selenium will automatically look through methods on these prototypes, using name patterns to recognize which ones are actions, assertions and locators. </li></ul>@testinggeek www.TestingGeek.com
  18. 18. Automation is incomplete without cross browser testing <ul><li>Selenium RC gem for different browser… </li></ul><ul><li>* iehta </li></ul><ul><li>* firefox </li></ul><ul><li>* iexplore </li></ul><ul><li>* chrome </li></ul><ul><li>* custom (for custom browsers) </li></ul>@testinggeek www.TestingGeek.com
  19. 19. https... <ul><li>Different options of selenium… </li></ul><ul><li>https </li></ul><ul><li>Multiwindow=<true/false> </li></ul><ul><li>Firefoxtemplate=<default template location> </li></ul>@testinggeek www.TestingGeek.com
  20. 20. Collecting all the gems and putting in the treasure chest @testinggeek www.TestingGeek.com
  21. 21. Is this the only treasure <ul><li>The real gems are in your minds in your brains. </li></ul><ul><li>Come up with a solution </li></ul><ul><li>Implement a simple but effective solution. </li></ul>@testinggeek www.TestingGeek.com
  22. 22. Automate using wrappers. @testinggeek www.TestingGeek.com SA <ul><li>Use a combination of tools.... </li></ul><ul><li>Selenium + Auto it. </li></ul><ul><li>Selenium + Batch files. </li></ul>
  23. 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. 24. Easy to read Natural language automation <ul><li>Simple easy to read language </li></ul><ul><li>POM. </li></ul>@testinggeek www.TestingGeek.com
  25. 25. Componentise your automation @testinggeek www.TestingGeek.com
  26. 26. Add dynamism... <ul><li>Connecting to the databses… </li></ul>@testinggeek www.TestingGeek.com
  27. 27. @testinggeek www.TestingGeek.com All this is less effective if automation does not run automatically......
  28. 28. Integrate with CI tools @testinggeek www.TestingGeek.com Mavenise your automation... And integrate them with Hudson...
  29. 29. Distribute the Tests @testinggeek www.TestingGeek.com With Selenium Grids or Hudson Slaves...
  30. 30. Integrate with CI tools @testinggeek www.TestingGeek.com What about Selenium 2.0 ?..... Will my old selenium tests run in 2.0?
  31. 31. Selenium 2.0 @testinggeek www.TestingGeek.com -Web Driver - Presentation redering etc.
  32. 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. 33. Thank You. <ul><li>Anand Ramdeo </li></ul><ul><li>www.TestingGeek.com </li></ul><ul><li>@testinggeek </li></ul><ul><li>www.AtlantisSw.com </li></ul><ul><li>[email_address] </li></ul>@testinggeek www.TestingGeek.com
  1. A particular slide catching your eye?

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

×