Gems Of Selenium
Upcoming SlideShare
Loading in...5
×
 

Gems Of Selenium

on

  • 3,727 views

Gems of Selenium

Gems of Selenium

Statistics

Views

Total Views
3,727
Views on SlideShare
3,099
Embed Views
628

Actions

Likes
1
Downloads
47
Comments
0

4 Embeds 628

http://skillsmatter.com 580
http://smash 37
http://www.slideshare.net 10
http://mail.skillsmatter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Gems Of Selenium Gems Of Selenium Presentation Transcript

  • 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
    • Time and Expense application built using Python+Plone @ Thoughtworks
    • Goal was “Fast, Fast, Fast”
    www.atlantissw.com | www.TestingGeek.com ADD ROW
  • 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
  • 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
  • Problems.. www.atlantissw.com | www.TestingGeek.com
  • 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
  • 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
    • The journey begins..
    • Want to automate ?
    • What are the common problems faced by people when using selenium IDE?
  • In search of treasure @testinggeek www.TestingGeek.com
    • Treasure is ….
    • Reliable automation.
    • Stable automation.
    • Maintainable automation.
    • Effective Automation .
  • @testinggeek www.TestingGeek.com Found my first Gem…. UI Element  How can this precious gem help me?
  • UI Element is... @testinggeek www.TestingGeek.com
    • ...a mapping between semantically meaningful names of elements on webpages, and the elements.
    • ...defined using JSON
  • 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
  • @testinggeek www.TestingGeek.com I want to extend Selenium with some new assertions,actions No problem User-extension.js is here for that.
  • 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
  • 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
  • https...
    • Different options of selenium…
    • https
    • Multiwindow=<true/false>
    • Firefoxtemplate=<default template location>
    @testinggeek www.TestingGeek.com
  • Collecting all the gems and putting in the treasure chest @testinggeek www.TestingGeek.com
  • 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
  • Automate using wrappers. @testinggeek www.TestingGeek.com SA
    • Use a combination of tools....
    • Selenium + Auto it.
    • Selenium + Batch files.
  • @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;); } } }
  • Easy to read Natural language automation
    • Simple easy to read language
    • POM.
    @testinggeek www.TestingGeek.com
  • Componentise your automation @testinggeek www.TestingGeek.com
  • Add dynamism...
    • Connecting to the databses…
    @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 2.0?
  • 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.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()); } } }
  • Thank You.
    • Anand Ramdeo
    • www.TestingGeek.com
    • @testinggeek
    • www.AtlantisSw.com
    • [email_address]
    @testinggeek www.TestingGeek.com