Your SlideShare is downloading. ×
Automated Web Testing Using Selenium
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

Automated Web Testing Using Selenium

6,984

Published on

Selenium/Tellurium framework introduction,Troubleshooting of Selenium

Selenium/Tellurium framework introduction,Troubleshooting of Selenium

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

No Downloads
Views
Total Views
6,984
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
166
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
  • Notes
  • -firefoxProfileTemplate ${selenium.home}/profiles/firefoxProfile
  • Add js to user-extensions.js: Selenium.prototype.getTableRows = function(locator) { /** * Gets the number of rows in a table. * * @param locator element locator for table * @return number of rows in the table, 0 if none */ var table = this.browserbot.findElement(locator); return table.rows.length.toString(); }; Selenium.java: String getTableRows(String locator); DefaultSelenium.java: public String getTableRows(String locator){ return commandProcessor.getString("getTableRows", new String[] {locator,}); } Test Method: public void testTables() throws InterruptedException{ selenium.open("http://www.w3schools.com/tags/tag_table.asp"); Thread. sleep (10000); String rows= selenium.getTableRows("//table[@id='table3']"); System. out .println("rows count= "+rows); }
  • Add js to user-extensions.js: Selenium.prototype.getTableRows = function(locator) { /** * Gets the number of rows in a table. * * @param locator element locator for table * @return number of rows in the table, 0 if none */ var table = this.browserbot.findElement(locator); return table.rows.length.toString(); }; Selenium.java: String getTableRows(String locator); DefaultSelenium.java: public String getTableRows(String locator){ return commandProcessor.getString("getTableRows", new String[] {locator,}); } Test Method: public void testTables() throws InterruptedException{ selenium.open("http://www.w3schools.com/tags/tag_table.asp"); Thread. sleep (10000); String rows= selenium.getTableRows("//table[@id='table3']"); System. out .println("rows count= "+rows); }
  • XPath builder can build the XPath from the composite locator, i.e., a set of attributes. Starting with version 0.6.0, Tellurium supports jQuery selectors to address the problem of poor performance of XPath in Internet Explorer. jQuery selector builders are used to automatically generate jQuery selectors instead of XPath with the following advantages: Faster performance in IE. Leverage the power of jQuery to retrieve bulk data from the web by testing with one method call. New features provided by jQuery attribute selectors.
  • Notes
  • Notes
  • Transcript

    • 1.  
    • 2. Automated Web Testing using Selenium Perficient China Waylon Zhang Yahoo!m: waylon_zhang2008 [email_address]
    • 3. Agenda
      • Warm-up
      • Introduction of Selenium Framework
      • Troubleshooting of Selenium
      • Practice
      • Q&A
    • 4. Warm-up
      • Google Advance Search Function
    • 5. Prerequisite
      • Development experience in Java language
      • Knowledge of Xpath language
      • Basic knowledge of HTML/Junit/TestNg
      • Knowledge of The Same Origin Policy
    • 6. What is Selenium?
      • Selenium is a suite of tools to automate web app testing across many platforms.
        • Selenium Core: DHTML test execution framework
        • Selenium IDE: Firefox extension – record and playback
        • Selenium Remote Control
          • Server: launches/kills browser, HTTP Proxy
          • Client libraries
        • Selenium Grid
          • Run Selenium tests in parallel
    • 7. Selenium components *Selenese is the set of Selenium Commands that run you tests. Don’t support If or For (While) statements C#, Java, Perl, PHP, Python, Ruby Selenese *Selenese Programming Languages Yes No No Support I&O Yes No No Need Jre Yes Yes No Different Domain Yes Yes Yes Support Https/SSL No No Yes AUT Server side installed Firefox, IE,Safari Firefox Firefox, IE,Safari Browsers Selenium Remote Control Selenium IDE Selenium Core
    • 8. How to use Selenium RC to develop
    • 9. How Selenium RC Works?
    • 10. How Selenium RC Works? (cont.)
    • 11. Selenium Solutions of HTTPS
      • Support HTTPS
        • IE (supported by default, configure IE browser)
        • FireFox (Selenium server doesn’t support add-ons configurations)
        • Safari (doesn’t support HTTPS configurations, so Selenium can’t run on it)
    • 12. Selenium to Test Click Flash (1/2)
    • 13. Selenium to test Click Flash (2/2)
      • Get help from Developer
        • javascript:WTKSendFlashClick( "{"Page":"Exterior", "ClickType":"angleClick","ClickParams":{"Direction":"left"}}" )
      • Use Selenium’s API
        • selenium.runScript(target)
    • 14. Selenium to test Ajax
      • Wait For It…
    • 15. Add API to Selenium (1/2)
      • Example: add Function of getTableRows(locator) to Selenium
        • Server Side
          • Add js to user-extensions.js
          • Save the user-extensions.js under the folder where selenium server resides
          • start selenium server with user-extensions.js
    • 16. Add API to Selenium (2/2)
      • Example: add Function of getTableRows(locator) to Selenium
        • Client Side
          • Add API to Selenium.java under package of com.thoughtworks.selenium
          • Add function to DefaultSelenium.java under package of com.thoughtworks.selenium
    • 17. Selenium Open Issues
      • How to test GWT web applications?
    • 18. Problems in Selenium
      • Verbose
        • Locators everywhere
      • Coupling
        • UI locators, actions, and assertions are coupled
      • Not expressive
        • What does the UI look like?
      • Speed
        • Since IE is lack of native XPath support, so tests run in IE are very slow
      • Record and Play
        • Re-labeling a button or moving it to another part of the window may require the test to be re-recorded
      • Refactor
        • Seems to be difficult
      • Reusable
        • Less likely
    • 19. Tellurium’s solution package com.perficient.tellurium.webapp.ui import org.tellurium.dsl.DslContext public class TelluriumModule extends DslContext { public void defineUi(){ ui.Container(uid: "root", clocator: [tag: "table", name: "Tellurium"]){ InputBox(uid: "firstName", clocator: [tag: "input", type: "text", name: "FirstName"]) InputBox(uid: "lastName", clocator: [tag: "input", type: "text", name: "LastName"]) InputBox(uid: "fullName", clocator: [tag: "input", type: "text", name: "FullName"]) InputBox(uid: "save", clocator: [tag: "input", type: "button", value: "Save"], respond: ["click"]) } } public void getFullName(String firstName,String lastName){ type "root.firstName",firstName type "root.lastName",lastName pause 500 click "root.save" } }
    • 20. What is Tellurium?
      • UI module based web testing framework built on top of Selenium
      • UI is defined in Groovy class and tests can be written in
        • Java (JUnit 4 or TestNG)
        • Groovy
        • Pure DSL script
      • Handles the mapping from Java object to UI
      • Reference: http:// code.google.com/p/aost /
    • 21. What challenges are addressed in Tellurium
      • No longer “record and play” style, but UI module oriented
      • Separated
      • Robust
      • Easy to refactor
    • 22. What challenges are addressed in Tellurium
      • Support jQuery Selector
        • useJQuerySelector()
        • disableJQuerySelector()
    • 23. Summarization: Advantage/Disadvantage
      • Involved new language
      • Very new, some potential risks we don’t know
      • No longer “record and play” style, but UI module oriented
      • Easy to refactor
      • Easy to use
      • UI and tests are separated
      • Faster performance in IE
      • Ideally only defining the HTML elements is required as the entry criteria of scripting
      Tellurium
      • Hard to refactor
      • Very slow in IE
      • UI locators, actions, and assertions are coupled
      • Record and Play requires little or no software development
      • It’s required to have both the HTML and the back-end code ready before we start scripting
      Selenium Disadvantage Advantage Pre-condition
    • 24. Best Practices
      • To Automate or Not to Automate? That is the Question!
      • The test framework should be approved, documented, reviewed.
      • Structure scripts with minimal dependencies.
      • Test automation is a fulltime effort, not a sideline. A dedicated team is required.
    • 25. Q&A
    • 26. References
      • Tellurium Framework
        • http:// code.google.com/p/aost /
      • Guidelines for Automation framework design
        • http://knowledgeinbox.com/articles/automation/frameworks/guidelines-for-automation-framework-design/
      • 10 Step Test Automation Approach - Guide for automation testers
        • http://testing.thoughtworks.com/article10step

    ×