SlideShare a Scribd company logo
Selenium Adam Goucher [email_address]
Lecture Objective Give students an introduction to web automation using the Selenium framework.
What is Selenium? Selenium is a web test tool that runs in the browser Because it runs in the browser, it does exactly what a user does
What tests can Selenium do? Browser compatibility – One script, many browsers Regression
Javascript Selenium is written in Javascript Javascript is how AJAX applications are written, so Selenium can test them too
Where to get it? Selenium can be downloaded and installed for free from  http:// www.openqa.org
QTP vs. Selenium QTP is not cross platform, Selenium is QTP costs a lot of money, Selenium is free QTP needs VBScript, Selenium has lots of language bindings The default format of testing in Selenium is HTML QTP can control other types of applications other than web
Multiple Seleniums? There are 3 versions of Selenium Selenium Core – The main component of Selenium Selenium RC – A scripting layer over Selenium Core Selenium IDE – a Firefox extension with record / playback functionality
Selenium IDE Selenium IDE adds a layer of Record / Playback to Selenium Is available for Firefox only
First Script link=sqa clickAndWait Submit01 clickAndWait label=Banking ct_category select qa queryTitle type /jobmining/ open Value Target Command
Checkpoints Of course, scripts wouldn’t be tests if they didn’t check something assert* tests fail the test immediately verify* tests keep track of results and continue the script regardless Job Requirements \n sdrfasf asserTextPresent Job Description \n dgds verifyTextPresent
Locators Selenium identifies what a component is through the use of a locator link=name dom=document.images[56] xpath=//table[@id='table1']//tr[4]/td[2] css=a[href="#id3"] Depending on your application, there might be major performance differences
Playback Playback of a single script is handled through the IDE Run – Go as fast as the script can process Walk – Slows down the execution Step – Executes the next step
Test Suites In order to run multiple scripts, you need to chain them together in a Test Suite Just another html table Runs inside Firefox, but not in S-IDE Saved in the same directory as the tests that are included in it
Test Suites <table> <tr> <td>Job Search test suite</td> </tr> <tr> <td><a target=&quot;testFrame&quot; href=“selenium-ide-01.html&quot;>Job Search</a></td> </tr> </table>
Test Suites The URL has a specific format chrome://selenium-ide/content/selenium/TestRunner.html?baseURL=http://your_hose:port&test=file:///c://temp/qa109/testsuite.html&auto=true&multiWindow=false
Selenium RC Selenium IDE is great for quick recording of tests, but it somewhat lacks for power Selenium RC gives you the ability to drive Selenium from a real programming language (Java, Perl, Python, Ruby, and more)
Why do you want a real language? By using Selenium inside a full fledged language you can do the following Seed the database Check the database Control external services Launch multiple windows Run multiple browsers in parallel In addition to running the actual test.
Proxy Because the commands for Selenium RC are embedded in a script, a proxy is needed to control the browser.
Python There are python bindings for most of the Selenium calls Watch for naming differences While not necessary, most use the unittest module with Selenium
import selenium, unittest class JM(unittest.TestCase): def setUp(self): protocol = &quot;http&quot; host = &quot;your host&quot; port = your_port_number self.verificationErrors = [] self.selenium = selenium.selenium(&quot;localhost&quot;, 4444, &quot;*chrome&quot;, &quot;%s://%s:%s&quot; % (protocol, host, port))  self.selenium.start() self.selenium.open(&quot;/jobmining/&quot;) def test_doSearch(self): sel = self.selenium sel.open(&quot;/jobmining/&quot;) sel.type(&quot;queryTitle&quot;, &quot;qa&quot;) sel.select(&quot;ct_category&quot;, &quot;label=Banking&quot;) sel.click(&quot;Submit01&quot;) sel.wait_for_page_to_load(&quot;30000&quot;) sel.click(&quot;link=sqa&quot;) sel.wait_for_page_to_load(&quot;30000&quot;) try: self.failUnless(sel.is_text_present(&quot;Job Description \n dgds&quot;)) except AssertionError, e: self.verificationErrors.append(str(e)) def tearDown(self): self.selenium.stop() if __name__ == &quot;__main__&quot;: unittest.main()
Data Driven One key concept when doing automation is to recycle your scripts through data driving them Use the underlying language you are using Selenium RC with to handle most of it for you
Same Origin Prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin – Mozilla security documentation In other words, cannot work across server boundries
Selenium Core Selenium Core is used by both Selenium IDE and RC Runs test suites on the same server to avoid the Same Origin problem Don’t have same flexibility as RC, but tests and code under test is in the same spot
Tips Start and stop your script from the same spot Record your script in S-IDE, then use it as a base for a S-RC script Use Firebug to give you the XPath
Designing for Selenium Proper use of tables and CSS div tags makes Selenium much easier
Support Because this is free, open source software there is no official support channel Mailing lists Wiki Forums Are your main sources of assistence. But don’t forget your peers!

More Related Content

PPTX
Automation - web testing with selenium
PPT
Selenium ppt
PPTX
Test Automation and Selenium
PPT
Selenium Automation Framework
PPT
Automated Web Testing Using Selenium
PPTX
Introduction to Selenium Web Driver
PDF
Web automation using selenium.ppt
PPT
Test Automation Framework Designs
Automation - web testing with selenium
Selenium ppt
Test Automation and Selenium
Selenium Automation Framework
Automated Web Testing Using Selenium
Introduction to Selenium Web Driver
Web automation using selenium.ppt
Test Automation Framework Designs

What's hot (20)

PPT
Selenium
PDF
SELENIUM PPT.pdf
PPT
PPTX
Automation Testing by Selenium Web Driver
PDF
Selenium IDE LOCATORS
PPT
Test automation using selenium
PPTX
Selenium WebDriver training
PPTX
An overview of selenium webdriver
PDF
Automation Testing using Selenium Webdriver
PPT
QSpiders - Automation using Selenium
PDF
Automation Testing using Selenium
PDF
Selenium Maven With Eclipse | Edureka
PPTX
Selenium WebDriver
PDF
Introduction to Selenium Automation
PPTX
TestNG with selenium
PPTX
Selenium introduction
PPT
Selenium Presentation at Engineering Colleges
PDF
Page Object Model and Implementation in Selenium
PDF
Selenium
Selenium
SELENIUM PPT.pdf
Automation Testing by Selenium Web Driver
Selenium IDE LOCATORS
Test automation using selenium
Selenium WebDriver training
An overview of selenium webdriver
Automation Testing using Selenium Webdriver
QSpiders - Automation using Selenium
Automation Testing using Selenium
Selenium Maven With Eclipse | Edureka
Selenium WebDriver
Introduction to Selenium Automation
TestNG with selenium
Selenium introduction
Selenium Presentation at Engineering Colleges
Page Object Model and Implementation in Selenium
Selenium
Ad

Similar to Selenium (20)

ODP
Automated ui testing with selenium. drupal con london 2011
PPT
Web App Testing With Selenium
KEY
Enterprise Build And Test In The Cloud
PPT
Testing Ajax Web Applications
PPT
Selenium Ide Tutorials
PPTX
Selenium Open Source Tool
PPTX
Selenium.ppt
PPT
Selenium Primer
PPT
Selenium
ODP
Basic testing with selenium
PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
ODP
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
PPT
Selenium RC Using Java and Maven + Maestro Integration
PPT
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
PPTX
Automated Web Testing With Selenium
ODP
Integration Testing in Python
PPTX
Selenium tutorial
PPT
Selenium classes in mumbai
PPTX
Mastering Test Automation: How To Use Selenium Successfully
Automated ui testing with selenium. drupal con london 2011
Web App Testing With Selenium
Enterprise Build And Test In The Cloud
Testing Ajax Web Applications
Selenium Ide Tutorials
Selenium Open Source Tool
Selenium.ppt
Selenium Primer
Selenium
Basic testing with selenium
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
Selenium RC Using Java and Maven + Maestro Integration
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Automated Web Testing With Selenium
Integration Testing in Python
Selenium tutorial
Selenium classes in mumbai
Mastering Test Automation: How To Use Selenium Successfully
Ad

More from Adam Goucher (20)

PDF
Lightsabers, Time Machines and other Automation Heuristics
PDF
SeleniumConf London 2019 - "Part 3: Practice what you Preach"
PDF
Is your Automation Infrastructure ‘Well Architected’?
PDF
Your Job Is To Collect Stories
PDF
[Automation] Trick-or-Treat Style
KEY
Proxy and Executor
PDF
Maintainable Automation FTW
PDF
Selenium Page Objects101
KEY
Selenium IDE - The future if plugin-y
PDF
You're doing it wrong
PDF
Namesmatter
PDF
Everything I learned about Agile I learned from Pirates
PDF
Agile Test Case Management
PDF
Mitigation
PDF
The Many Hats of a Tester
PDF
Testing inspiration
PDF
Archetypes
PDF
Agile Hats Art Show
PDF
Quality through the lens of Astrophysics
PDF
Legend of Zealot Anarchist Robot
Lightsabers, Time Machines and other Automation Heuristics
SeleniumConf London 2019 - "Part 3: Practice what you Preach"
Is your Automation Infrastructure ‘Well Architected’?
Your Job Is To Collect Stories
[Automation] Trick-or-Treat Style
Proxy and Executor
Maintainable Automation FTW
Selenium Page Objects101
Selenium IDE - The future if plugin-y
You're doing it wrong
Namesmatter
Everything I learned about Agile I learned from Pirates
Agile Test Case Management
Mitigation
The Many Hats of a Tester
Testing inspiration
Archetypes
Agile Hats Art Show
Quality through the lens of Astrophysics
Legend of Zealot Anarchist Robot

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Modernizing your data center with Dell and AMD
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Modernizing your data center with Dell and AMD
20250228 LYD VKU AI Blended-Learning.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation theory and applications.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Selenium

  • 1. Selenium Adam Goucher [email_address]
  • 2. Lecture Objective Give students an introduction to web automation using the Selenium framework.
  • 3. What is Selenium? Selenium is a web test tool that runs in the browser Because it runs in the browser, it does exactly what a user does
  • 4. What tests can Selenium do? Browser compatibility – One script, many browsers Regression
  • 5. Javascript Selenium is written in Javascript Javascript is how AJAX applications are written, so Selenium can test them too
  • 6. Where to get it? Selenium can be downloaded and installed for free from http:// www.openqa.org
  • 7. QTP vs. Selenium QTP is not cross platform, Selenium is QTP costs a lot of money, Selenium is free QTP needs VBScript, Selenium has lots of language bindings The default format of testing in Selenium is HTML QTP can control other types of applications other than web
  • 8. Multiple Seleniums? There are 3 versions of Selenium Selenium Core – The main component of Selenium Selenium RC – A scripting layer over Selenium Core Selenium IDE – a Firefox extension with record / playback functionality
  • 9. Selenium IDE Selenium IDE adds a layer of Record / Playback to Selenium Is available for Firefox only
  • 10. First Script link=sqa clickAndWait Submit01 clickAndWait label=Banking ct_category select qa queryTitle type /jobmining/ open Value Target Command
  • 11. Checkpoints Of course, scripts wouldn’t be tests if they didn’t check something assert* tests fail the test immediately verify* tests keep track of results and continue the script regardless Job Requirements \n sdrfasf asserTextPresent Job Description \n dgds verifyTextPresent
  • 12. Locators Selenium identifies what a component is through the use of a locator link=name dom=document.images[56] xpath=//table[@id='table1']//tr[4]/td[2] css=a[href=&quot;#id3&quot;] Depending on your application, there might be major performance differences
  • 13. Playback Playback of a single script is handled through the IDE Run – Go as fast as the script can process Walk – Slows down the execution Step – Executes the next step
  • 14. Test Suites In order to run multiple scripts, you need to chain them together in a Test Suite Just another html table Runs inside Firefox, but not in S-IDE Saved in the same directory as the tests that are included in it
  • 15. Test Suites <table> <tr> <td>Job Search test suite</td> </tr> <tr> <td><a target=&quot;testFrame&quot; href=“selenium-ide-01.html&quot;>Job Search</a></td> </tr> </table>
  • 16. Test Suites The URL has a specific format chrome://selenium-ide/content/selenium/TestRunner.html?baseURL=http://your_hose:port&test=file:///c://temp/qa109/testsuite.html&auto=true&multiWindow=false
  • 17. Selenium RC Selenium IDE is great for quick recording of tests, but it somewhat lacks for power Selenium RC gives you the ability to drive Selenium from a real programming language (Java, Perl, Python, Ruby, and more)
  • 18. Why do you want a real language? By using Selenium inside a full fledged language you can do the following Seed the database Check the database Control external services Launch multiple windows Run multiple browsers in parallel In addition to running the actual test.
  • 19. Proxy Because the commands for Selenium RC are embedded in a script, a proxy is needed to control the browser.
  • 20. Python There are python bindings for most of the Selenium calls Watch for naming differences While not necessary, most use the unittest module with Selenium
  • 21. import selenium, unittest class JM(unittest.TestCase): def setUp(self): protocol = &quot;http&quot; host = &quot;your host&quot; port = your_port_number self.verificationErrors = [] self.selenium = selenium.selenium(&quot;localhost&quot;, 4444, &quot;*chrome&quot;, &quot;%s://%s:%s&quot; % (protocol, host, port)) self.selenium.start() self.selenium.open(&quot;/jobmining/&quot;) def test_doSearch(self): sel = self.selenium sel.open(&quot;/jobmining/&quot;) sel.type(&quot;queryTitle&quot;, &quot;qa&quot;) sel.select(&quot;ct_category&quot;, &quot;label=Banking&quot;) sel.click(&quot;Submit01&quot;) sel.wait_for_page_to_load(&quot;30000&quot;) sel.click(&quot;link=sqa&quot;) sel.wait_for_page_to_load(&quot;30000&quot;) try: self.failUnless(sel.is_text_present(&quot;Job Description \n dgds&quot;)) except AssertionError, e: self.verificationErrors.append(str(e)) def tearDown(self): self.selenium.stop() if __name__ == &quot;__main__&quot;: unittest.main()
  • 22. Data Driven One key concept when doing automation is to recycle your scripts through data driving them Use the underlying language you are using Selenium RC with to handle most of it for you
  • 23. Same Origin Prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin – Mozilla security documentation In other words, cannot work across server boundries
  • 24. Selenium Core Selenium Core is used by both Selenium IDE and RC Runs test suites on the same server to avoid the Same Origin problem Don’t have same flexibility as RC, but tests and code under test is in the same spot
  • 25. Tips Start and stop your script from the same spot Record your script in S-IDE, then use it as a base for a S-RC script Use Firebug to give you the XPath
  • 26. Designing for Selenium Proper use of tables and CSS div tags makes Selenium much easier
  • 27. Support Because this is free, open source software there is no official support channel Mailing lists Wiki Forums Are your main sources of assistence. But don’t forget your peers!