0
Selenium Web Test Automation Tool Rohit Nayak Talentica Software
Agenda <ul><li>Demo </li></ul><ul><li>What is Selenium? Why? Pros/Cons </li></ul><ul><li>Writing test cases using Selenium...
Demo <ul><li>Record a test in Selenium IDE </li></ul><ul><li>Review test in Selenese HTML </li></ul>
Similar Tools <ul><li>Bad Boy  </li></ul><ul><li>Sahi  </li></ul><ul><li>Silk Test, QTP (paid) </li></ul><ul><li>Grinder <...
What is Selenium? <ul><li>Test tool for web applications </li></ul><ul><li>Actually runs in a browser </li></ul><ul><li>Su...
Advantages <ul><li>Free! </li></ul><ul><li>Can test across multiple browsers  </li></ul><ul><li>Mimics actual user experie...
Common Problems in Web Testing <ul><li>Record/replay is not reusable, is fragile </li></ul><ul><li>Managing test cases </l...
Problems  <ul><li>Performance (~HTMLUnit, WebTest) </li></ul><ul><li>Reporting (~WebTest) </li></ul><ul><li>Fancy CSS/Ajax...
Best Practices <ul><li>All tests should be source control </li></ul><ul><li>One test per function not per page </li></ul><...
Code for testability <ul><li>Demand this from Development </li></ul><ul><li>Visible feedback on actions (hidden values in ...
Demo 2 <ul><li>Show same test written in Java </li></ul><ul><li>Show same test written in PHP </li></ul>
Java Example <ul><li>public void testGoogleTestSearch()  </li></ul><ul><li>throws Exception </li></ul><ul><li>{ </li></ul>...
JUnit  <ul><li>public void setUp() throws Exception </li></ul><ul><li>{ </li></ul><ul><ul><li>selenium = new DefaultSeleni...
Some Selenese Commands submit type isTextPresent createCookie isElementPresent fireEvent dragdrop open goBack Input mouseO...
Element locators <ul><li>ID: id=foo </li></ul><ul><li>Name: name=foo </li></ul><ul><li>First ID, then name: identifier=foo...
Selenium Modules <ul><li>Selenium Core </li></ul><ul><li>Selenium IDE </li></ul><ul><li>Selenium Remote Control </li></ul>...
How it works
Selenium Usage Patterns <ul><li>Creating Tests </li></ul><ul><li>Recording using Selenium IDE </li></ul><ul><li>Writing te...
Advanced <ul><li>Cubic Test </li></ul><ul><li>HRMES </li></ul><ul><li>Selenium Grid </li></ul><ul><li>BrowserMob </li></ul...
Upcoming SlideShare
Loading in...5
×

Introduction to Selenium

10,155

Published on

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

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
10,155
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
383
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to Selenium"

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

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

×