Introduction to Selenium

  • 9,491 views
Uploaded on

This is a quick introduction to the Selenium Test Automation tool.

This is a quick introduction to the Selenium Test Automation tool.

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

Views

Total Views
9,491
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
372
Comments
1
Likes
4

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. Selenium Web Test Automation Tool Rohit Nayak Talentica Software
  • 2. Agenda
    • Demo
    • What is Selenium? Why? Pros/Cons
    • Writing test cases using Selenium
    • Architecture
    • Best Practices
  • 3. Demo
    • Record a test in Selenium IDE
    • Review test in Selenese HTML
  • 4. Similar Tools
    • Bad Boy
    • Sahi
    • Silk Test, QTP (paid)
    • Grinder
    • Others: Watir, OpenSTA
  • 5. What is Selenium?
    • Test tool for web applications
    • Actually runs in a browser
    • Supports tests in many languages
    • Selenese (pure HTML, no backend required)
    • Java, C#, Perl, Python, Ruby
    • Record/playback (Firefox plugin: Selenium IDE)
    • Open Source with corporate backing
    • Lives at selenium.org
  • 6. Advantages
    • Free!
    • Can test across multiple browsers
    • Mimics actual user experience
    • Ajax / CSS support
    • Use language of choice
    • Large user community
    • Great tools: CubicTest, Grid, HRMES
  • 7. Common Problems in Web Testing
    • Record/replay is not reusable, is fragile
    • Managing test cases
    • UI Changes make tests brittle
  • 8. Problems
    • Performance (~HTMLUnit, WebTest)
    • Reporting (~WebTest)
    • Fancy CSS/Ajax needs tricky coding
    • Data dependency should be avoided
  • 9. Best Practices
    • All tests should be source control
    • One test per function not per page
    • Nightly runs
    • Separate environ specific variables
    • Automate fixed function, others manual
    • Abstract out functionality and reuse them
    • Parameterize your tests
    • Framework!!
  • 10. Code for testability
    • Demand this from Development
    • Visible feedback on actions (hidden values in case div appears/disappears)
    • (dev-only) url for database teardown
    • Use of IDs for important UI elements
    • Good HTML
    • Good logs
  • 11. Demo 2
    • Show same test written in Java
    • Show same test written in PHP
  • 12. Java Example
    • public void testGoogleTestSearch()
    • throws Exception
    • {
      • selenium.open("http://www.google.com/webhp");
      • assertEquals("Google", selenium.getTitle());
      • selenium.type("q", "Selenium OpenQA");
      • selenium.click("btnG");
      • selenium.waitForPageToLoad("5000");
      • assertEquals("Selenium OpenQA - Google Search",
      • selenium.getTitle());
    • }
  • 13. JUnit
    • public void setUp() throws Exception
    • {
      • selenium = new DefaultSelenium(
      • "localhost", 4444, "*chrome", "http://www.google.com");
      • selenium.start();
    • }
    • public void tearDown() throws Exception
    • {
    • selenium.stop();
    • }
  • 14. Some Selenese Commands submit type isTextPresent createCookie isElementPresent fireEvent dragdrop open goBack Input mouseOver storeText assertSelected keyPress getTitle isVisible waitForCondition click
  • 15. Element locators
    • ID: id=foo
    • Name: name=foo
    • First ID, then name: identifier=foo
    • DOM: document.forms[‘myform’].myDropdown
    • XPath: xpath=//table[@id='table1']//tr[4]/td[2]
    • Link Text: link=sometext
    • Sensible defaults, e.g. xpath if starts with //
  • 16. Selenium Modules
    • Selenium Core
    • Selenium IDE
    • Selenium Remote Control
    • Client Drivers
    • JS Extensions
  • 17. How it works
  • 18. Selenium Usage Patterns
    • Creating Tests
    • Recording using Selenium IDE
    • Writing tests in Selenese
    • Building a Framework
    • Running Tests
    • Through IDE
    • Using Selenium RC
    • Using Framework
  • 19. Advanced
    • Cubic Test
    • HRMES
    • Selenium Grid
    • BrowserMob
    • Tellurium