SlideShare a Scribd company logo
Automated Web Testing with SeleniumBy Jodie MinersPresented to SBTUG30 September 2009
What is Selenium?It’s Free and Open SourceIt originally came from ThoughtworksIt comes in 3 flavoursIDE (Integrated Development Environment) – for recording test cases in FirefoxRC (Remote Control) – for running automated tests on any browserGrid – for large scale test runs of multiple tests in parallel You can get it here http://www.seleniumhq.org/“Selenium tests run directly in a browser, just as real users do”
Why use SeleniumYou are always doing the same steps over and over againYou need to get to the last step in a wizard to test that stepYou want to pre-fill some dummy dataFormal Functional and Regression TestingLoad Testing *
Selenium IDEA Firefox add-on that allows you to record tests for playing back in any browser.Very simple to useAllows non developers to get up and running with automated testing very quicklyThen they can pass on to developers for refinement or inclusion into a continuous build systemCan extend it easily with a little bit of HTML knowledge
Recording and PlaybackFirst Decide what you are testing and work out your test case(s)IDE DemoRecord a testPlay back a testDebug a testStep through a testCapture screen shotAsserts
SeleneseThe language of selenium. It is quite easy to learn3 parts to itCommand – eg TypeLocator – eg Input BoxValue – eg “ABC”Can easily be written in HTMLThings to help build the IDE testsAssert / Wait for Page to Load / Verify Text Present / Verify element present on each pageSlow things down with pauses and timeoutsStep through firs then run, add pauses and wait’s if it fails because it’s going too fastAdd think times
Selenese LocatorsCan Locate page elements by the following 4 methodsID, DOM, Xpath, CSSIDE recorderwill choose the best one to use, or you can choose which ever method if you are coding the tests. Can also use Wildcards and Regular Expressions See http://seleniumhq.org/docs/04_selenese_commands.html for more info - it’s very comprehensiveInstall Firebug to help with working out the locators
Selenium RCTakes a little time and effort to get it up and runningCan then run your tests scripts from IDE in different browsersWith good results reportingOr write the tests in code and automate the testing even furtherIssuesNeed to Install and use JavaVery command line / batch file basedSelenium RC Demo
DemoRun the test in FirefoxRun the test in IERun the test in ChromeNote that they are all in sequence
Coding your testsCoding of Selenium testing can be done inJava, Ruby, Groovy, C#, Perl, PHP, PythonMost examples are Java or Ruby, not that many people using C#Add If statementsEg if stock exists then add to cart (rather than having an error message)Add looping statementsFor each product found, add to cartEasier to add parameterisation or data driven testseg have a list of products in a file or table – add each of the products to the cart(you can do data driven tests in IDE – see here http://wiki.openqa.org/display/SEL/datadriven )Multiple test runsRun the test 4 times, each time logged in as a different userSelenium Code Demo with NUnit
DemoShow the codePaste the selenese inShow NunitvsMSTest?Run the Nunit testHave one prepared ready to go
ReportingThere is a great reporting framework if you code in Java or use TestNGLogging Selenium http://loggingselenium.sourceforge.net/For C# these are the options: Just capture the Selenium output to a fileCode a reporting framework yourselfUse the Visual Studio Team System Test Edition frameworkUse the NUnit reportingI use a combination of VSTT reporting and some additional logging to a database that I created myself.
Selenium GridScale out the tests to run on multiple browsers at the same timeSaves time in doing the testingBut you need to rely on the reporting as you can’t watch 5+ browsers do the testingGreat tutorial and demo here http://selenium-grid.seleniumhq.org/Requires Java SDK and Apache Ant to run
My Grid Setup
Taking the Grid FurtherScale out your grid to the Cloud using Amazon EC2 serviceOr use a third party serviceSauce Labs http://www.saucelabs.comIn early betaUses your own code So can set up the code to either run locally or via web Current special US$100 for 5000 minutesLots of Browser / OS combinationsTest Environment PictureBrowserMobhttp://www.browsermob.comTime consuming to set upSome limitations on which selenium commands can be usedLots of options (eg can test with specific bandwidth limitations)Can be used as for http requests only, as well as real browser testsAround US$2.00 per browser per hour
More Advanced TopicsUI Element mapping – How developers can make it easier for end users to build Selenium tests using element locator names that they can understandhttp://ttwhy.org/home/blog/2007/05/12/selenium-ui-element-locator/Using Xpath references with the Ext-JS javascript framework http://www.xeolabs.com/portal/node/34
Load TestingPurists say Selenium is not for load testingThat is mainly because of the hardware required to run multiple browsers on the same machine.I hit limits of 5-8 browsers on a standard desktop machine and 12-15 browsers on a serverUse Browser Mob or SauceLabs to overcome these issues.Also as Selenium uses Real Browsers it requires real logins to simulate real loads – so you have to log in as real users on your systemIt does not do virtual load and virtual users
Recording in IE (just for @aussienick)Watin for .nethttp://watin.sourceforge.net/Has a built in recorder for IEThere are also Watir (ruby), and Watij (java) variants http://wtr.rubyforge.org/Visual Studio Team System 2008 Test Edition (VSTT)Visual Studio Team System 2010 Test Edition + Team Foundation ServerLooks FantasticWill also record and play back windows appsMust use TFS

More Related Content

What's hot (20)

PPT
Selenium Primer
Debashish Chakrabarty
 
PDF
Selenium Ide Tutorial
metapix
 
PDF
Selenium IDE Introduction, Installation and Working
Disha Srivastava
 
PPT
Selenium
Daksh Sharma
 
PPTX
Selenium
Satyam Pandey
 
PPTX
Automated Testing Overview
antsh
 
PPT
Selenium
Anil Babu
 
PDF
Basics of Selenium IDE,Core, Remote Control
usha kannappan
 
PPT
Selenium
Adam Goucher
 
PPT
Selenium Primer
gueste1e4db
 
PPT
Selenium
Ruturaj Doshi
 
PDF
Jenkins & Selenium
adamcarmi
 
ODP
Automated UI testing with Selenium
Yuriy Gerasimov
 
PDF
First steps with selenium rc
Dang Nguyen
 
PPT
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
PPTX
CI / CD w/ Codeception
Tudor Barbu
 
PDF
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
PDF
Practical Tips & Tricks for Selenium Test Automation
Sauce Labs
 
PPTX
Selenium WebDriver - Test automation for web applications
TSundberg
 
Selenium Primer
Debashish Chakrabarty
 
Selenium Ide Tutorial
metapix
 
Selenium IDE Introduction, Installation and Working
Disha Srivastava
 
Selenium
Daksh Sharma
 
Selenium
Satyam Pandey
 
Automated Testing Overview
antsh
 
Selenium
Anil Babu
 
Basics of Selenium IDE,Core, Remote Control
usha kannappan
 
Selenium
Adam Goucher
 
Selenium Primer
gueste1e4db
 
Selenium
Ruturaj Doshi
 
Jenkins & Selenium
adamcarmi
 
Automated UI testing with Selenium
Yuriy Gerasimov
 
First steps with selenium rc
Dang Nguyen
 
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
CI / CD w/ Codeception
Tudor Barbu
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
Practical Tips & Tricks for Selenium Test Automation
Sauce Labs
 
Selenium WebDriver - Test automation for web applications
TSundberg
 

Similar to Automated Web Testing With Selenium (20)

PPT
Selenium (1)
onlinemindq
 
PPT
Karate _Framework.ppt
SamKhan531862
 
PPT
Selenium Presentation at Engineering Colleges
Vijay Rangaiah
 
PPT
Selenium
BugRaptors
 
DOC
Sel
Sandeep A R
 
PPT
Automation using Selenium Your score increases as you pick a category, fill o...
SENTHILR44
 
PPT
Test_Automation using Selenium.ppt
SamKhan531862
 
PPT
Web Test Automation with Selenium
vivek_prahlad
 
PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
PDF
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
PPT
Selenium By Pravin Mishra
Pravin Mishra
 
PPT
Selenium
tanvir afzal
 
PPT
Tanvir Afzal: Selenium
SQABD
 
PDF
Selenium by using JAVA
mahirayavarapu
 
PDF
white and grey modern website application education project group school pres...
DreamTheory
 
PDF
selenium
ayeshsiddika
 
PPT
Selenium
shrialinda
 
PPT
JavaScript Unit Testing
Christian Johansen
 
PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Ondřej Machulda
 
Selenium (1)
onlinemindq
 
Karate _Framework.ppt
SamKhan531862
 
Selenium Presentation at Engineering Colleges
Vijay Rangaiah
 
Selenium
BugRaptors
 
Automation using Selenium Your score increases as you pick a category, fill o...
SENTHILR44
 
Test_Automation using Selenium.ppt
SamKhan531862
 
Web Test Automation with Selenium
vivek_prahlad
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Selenium By Pravin Mishra
Pravin Mishra
 
Selenium
tanvir afzal
 
Tanvir Afzal: Selenium
SQABD
 
Selenium by using JAVA
mahirayavarapu
 
white and grey modern website application education project group school pres...
DreamTheory
 
selenium
ayeshsiddika
 
Selenium
shrialinda
 
JavaScript Unit Testing
Christian Johansen
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Ondřej Machulda
 
Ad

Recently uploaded (20)

PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Digital Circuits, important subject in CS
contactparinay1
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Ad

Automated Web Testing With Selenium

  • 1. Automated Web Testing with SeleniumBy Jodie MinersPresented to SBTUG30 September 2009
  • 2. What is Selenium?It’s Free and Open SourceIt originally came from ThoughtworksIt comes in 3 flavoursIDE (Integrated Development Environment) – for recording test cases in FirefoxRC (Remote Control) – for running automated tests on any browserGrid – for large scale test runs of multiple tests in parallel You can get it here http://www.seleniumhq.org/“Selenium tests run directly in a browser, just as real users do”
  • 3. Why use SeleniumYou are always doing the same steps over and over againYou need to get to the last step in a wizard to test that stepYou want to pre-fill some dummy dataFormal Functional and Regression TestingLoad Testing *
  • 4. Selenium IDEA Firefox add-on that allows you to record tests for playing back in any browser.Very simple to useAllows non developers to get up and running with automated testing very quicklyThen they can pass on to developers for refinement or inclusion into a continuous build systemCan extend it easily with a little bit of HTML knowledge
  • 5. Recording and PlaybackFirst Decide what you are testing and work out your test case(s)IDE DemoRecord a testPlay back a testDebug a testStep through a testCapture screen shotAsserts
  • 6. SeleneseThe language of selenium. It is quite easy to learn3 parts to itCommand – eg TypeLocator – eg Input BoxValue – eg “ABC”Can easily be written in HTMLThings to help build the IDE testsAssert / Wait for Page to Load / Verify Text Present / Verify element present on each pageSlow things down with pauses and timeoutsStep through firs then run, add pauses and wait’s if it fails because it’s going too fastAdd think times
  • 7. Selenese LocatorsCan Locate page elements by the following 4 methodsID, DOM, Xpath, CSSIDE recorderwill choose the best one to use, or you can choose which ever method if you are coding the tests. Can also use Wildcards and Regular Expressions See http://seleniumhq.org/docs/04_selenese_commands.html for more info - it’s very comprehensiveInstall Firebug to help with working out the locators
  • 8. Selenium RCTakes a little time and effort to get it up and runningCan then run your tests scripts from IDE in different browsersWith good results reportingOr write the tests in code and automate the testing even furtherIssuesNeed to Install and use JavaVery command line / batch file basedSelenium RC Demo
  • 9. DemoRun the test in FirefoxRun the test in IERun the test in ChromeNote that they are all in sequence
  • 10. Coding your testsCoding of Selenium testing can be done inJava, Ruby, Groovy, C#, Perl, PHP, PythonMost examples are Java or Ruby, not that many people using C#Add If statementsEg if stock exists then add to cart (rather than having an error message)Add looping statementsFor each product found, add to cartEasier to add parameterisation or data driven testseg have a list of products in a file or table – add each of the products to the cart(you can do data driven tests in IDE – see here http://wiki.openqa.org/display/SEL/datadriven )Multiple test runsRun the test 4 times, each time logged in as a different userSelenium Code Demo with NUnit
  • 11. DemoShow the codePaste the selenese inShow NunitvsMSTest?Run the Nunit testHave one prepared ready to go
  • 12. ReportingThere is a great reporting framework if you code in Java or use TestNGLogging Selenium http://loggingselenium.sourceforge.net/For C# these are the options: Just capture the Selenium output to a fileCode a reporting framework yourselfUse the Visual Studio Team System Test Edition frameworkUse the NUnit reportingI use a combination of VSTT reporting and some additional logging to a database that I created myself.
  • 13. Selenium GridScale out the tests to run on multiple browsers at the same timeSaves time in doing the testingBut you need to rely on the reporting as you can’t watch 5+ browsers do the testingGreat tutorial and demo here http://selenium-grid.seleniumhq.org/Requires Java SDK and Apache Ant to run
  • 15. Taking the Grid FurtherScale out your grid to the Cloud using Amazon EC2 serviceOr use a third party serviceSauce Labs http://www.saucelabs.comIn early betaUses your own code So can set up the code to either run locally or via web Current special US$100 for 5000 minutesLots of Browser / OS combinationsTest Environment PictureBrowserMobhttp://www.browsermob.comTime consuming to set upSome limitations on which selenium commands can be usedLots of options (eg can test with specific bandwidth limitations)Can be used as for http requests only, as well as real browser testsAround US$2.00 per browser per hour
  • 16. More Advanced TopicsUI Element mapping – How developers can make it easier for end users to build Selenium tests using element locator names that they can understandhttp://ttwhy.org/home/blog/2007/05/12/selenium-ui-element-locator/Using Xpath references with the Ext-JS javascript framework http://www.xeolabs.com/portal/node/34
  • 17. Load TestingPurists say Selenium is not for load testingThat is mainly because of the hardware required to run multiple browsers on the same machine.I hit limits of 5-8 browsers on a standard desktop machine and 12-15 browsers on a serverUse Browser Mob or SauceLabs to overcome these issues.Also as Selenium uses Real Browsers it requires real logins to simulate real loads – so you have to log in as real users on your systemIt does not do virtual load and virtual users
  • 18. Recording in IE (just for @aussienick)Watin for .nethttp://watin.sourceforge.net/Has a built in recorder for IEThere are also Watir (ruby), and Watij (java) variants http://wtr.rubyforge.org/Visual Studio Team System 2008 Test Edition (VSTT)Visual Studio Team System 2010 Test Edition + Team Foundation ServerLooks FantasticWill also record and play back windows appsMust use TFS
  • 19. ReferencesSelenium Tutorial http://dynamitemap.com/selenium/including a good videoFull list of software testing tools http://www.softwareqatest.com/qatweb1.htmlVSTT Quick Reference http://vstt2008qrg.codeplex.com/
  • 20. X-Path ReferencesThere is a great deal of help online for Xpath, here are some of the best sites I’ve foundXpath reference http://www.w3schools.com/Xpath/default.aspSome nice simple examples (on the Xpath tab) http://confluence.sakaiproject.org/display/QA/SeleniumQuick Reference Card http://confluence.sakaiproject.org/display/QA/SeleniumMSDN http://msdn.microsoft.com/en-us/library/ms256115.aspxGreat tutorial with lots of examples http://www.zvon.org/xxl/XPathTutorial/General/examples.htmlSelenium Wiki Xpath reference http://wiki.openqa.org/display/SEL/Help+With+XPath