SlideShare uma empresa Scribd logo
1 de 18
Automated Web Testing with Selenium By Jodie Miners Presented to SBTUG 30 September 2009
What is Selenium? It’s Free and Open Source It originally came from Thoughtworks It comes in 3 flavours IDE (Integrated Development Environment) – for recording test cases in Firefox RC (Remote Control) – for running automated tests on any browser Grid – 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 Selenium You are always doing the same steps over and over again You need to get to the last step in a wizard to test that step You want to pre-fill some dummy data Formal Functional and Regression Testing Load Testing *
Selenium IDE A Firefox add-on that allows you to record tests for playing back in any browser. Very simple to use Allows non developers to get up and running with automated testing very quickly Then they can pass on to developers for refinement or inclusion into a continuous build system Can extend it easily with a little bit of HTML knowledge
Recording and Playback First Decide what you are testing and work out your test case(s) IDE Demo Record a test Play back a test Debug a test Step through a test Capture screen shot Asserts
Selenese The language of selenium. It is quite easy to learn 3 parts to it Command – eg Type Locator – eg Input Box Value – eg “ABC” Can easily be written in HTML Things to help build the IDE tests Assert / Wait for Page to Load / Verify Text Present / Verify element present on each page Slow things down with pauses and timeouts Step through firs then run, add pauses and wait’s if it fails because it’s going too fast Add think times
Selenese Locators Can Locate page elements by the following 4 methods ID, DOM, Xpath, CSS IDE 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 comprehensive Install Firebug to help with working out the locators
Selenium RC Takes a little time and effort to get it up and running Can then run your tests scripts from IDE in different browsers With good results reporting Or write the tests in code and automate the testing even further Issues Need to Install and use Java Very command line / batch file based Selenium RC Demo
Demo Run the test in Firefox Run the test in IE Run the test in Chrome Note that they are all in sequence
Coding your tests Coding of Selenium testing can be done in Java, Ruby, Groovy, C#, Perl, PHP, Python Most examples are Java or Ruby, not that many people using C# Add If statements Eg if stock exists then add to cart (rather than having an error message) Add looping statements For each product found, add to cart Easier to add parameterisation or data driven tests eg 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 runs Run the test 4 times, each time logged in as a different user Selenium Code Demo with NUnit
Demo Show the code Paste the selenese in Show NunitvsMSTest? Run the Nunit test Have one prepared ready to go
Reporting There is a great reporting framework if you code in Java or use TestNG Logging Selenium http://loggingselenium.sourceforge.net/ For C# these are the options:  Just capture the Selenium output to a file Code a reporting framework yourself Use the Visual Studio Team System Test Edition framework Use the NUnit reporting I use a combination of VSTT reporting and some additional logging to a database that I created myself.
Selenium Grid Scale out the tests to run on multiple browsers at the same time Saves time in doing the testing But you need to rely on the reporting as you can’t watch 5+ browsers do the testing Great tutorial and demo here http://selenium-grid.seleniumhq.org/ Requires Java SDK and Apache Ant to run
My Grid Setup
Taking the Grid Further Scale out your grid to the Cloud using Amazon EC2 service Or use a third party service Sauce Labs http://www.saucelabs.com In early beta Uses your own code  So can set up the code to either run locally or via web  Current special US$100 for 5000 minutes Lots of Browser / OS combinations Test Environment Picture BrowserMobhttp://www.browsermob.com Time consuming to set up Some limitations on which selenium commands can be used Lots of options (eg can test with specific bandwidth limitations) Can be used as for http requests only, as well as real browser tests Around US$2.00 per browser per hour
More Advanced Topics UI Element mapping – How developers can make it easier for end users to build Selenium tests using element locator names that they can understand http://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 Testing Purists say Selenium is not for load testing That 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 server Use 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 system It does not do virtual load and virtual users
Recording in IE (just for @aussienick) Watin for .net http://watin.sourceforge.net/ Has a built in recorder for IE There 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 Server Looks Fantastic Will also record and play back windows apps Must use TFS

Mais conteúdo relacionado

Mais procurados

Selenium Ide Tutorial
Selenium Ide TutorialSelenium Ide Tutorial
Selenium Ide Tutorialmetapix
 
Selenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and WorkingSelenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and WorkingDisha Srivastava
 
Automated Testing Overview
Automated Testing OverviewAutomated Testing Overview
Automated Testing Overviewantsh
 
Basics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote ControlBasics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote Controlusha kannappan
 
Jenkins & Selenium
Jenkins & SeleniumJenkins & Selenium
Jenkins & Seleniumadamcarmi
 
Automated UI testing with Selenium
Automated UI testing with SeleniumAutomated UI testing with Selenium
Automated UI testing with SeleniumYuriy Gerasimov
 
First steps with selenium rc
First steps with selenium rcFirst steps with selenium rc
First steps with selenium rcDang Nguyen
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ CodeceptionTudor Barbu
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupDave Haeffner
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationSauce Labs
 
Selenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsSelenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsTSundberg
 

Mais procurados (20)

Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Java notes
Java notesJava notes
Java notes
 
Selenium Ide Tutorial
Selenium Ide TutorialSelenium Ide Tutorial
Selenium Ide Tutorial
 
Selenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and WorkingSelenium IDE Introduction, Installation and Working
Selenium IDE Introduction, Installation and Working
 
Selenium
SeleniumSelenium
Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Automated Testing Overview
Automated Testing OverviewAutomated Testing Overview
Automated Testing Overview
 
Selenium
SeleniumSelenium
Selenium
 
Basics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote ControlBasics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote Control
 
Selenium
SeleniumSelenium
Selenium
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Selenium
SeleniumSelenium
Selenium
 
Jenkins & Selenium
Jenkins & SeleniumJenkins & Selenium
Jenkins & Selenium
 
Automated UI testing with Selenium
Automated UI testing with SeleniumAutomated UI testing with Selenium
Automated UI testing with Selenium
 
First steps with selenium rc
First steps with selenium rcFirst steps with selenium rc
First steps with selenium rc
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ Codeception
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
 
Selenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsSelenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applications
 

Semelhante a Automated Web Testing With Selenium

Karate _Framework.ppt
Karate _Framework.pptKarate _Framework.ppt
Karate _Framework.pptSamKhan531862
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesVijay Rangaiah
 
Test_Automation using Selenium.ppt
Test_Automation using Selenium.pptTest_Automation using Selenium.ppt
Test_Automation using Selenium.pptSamKhan531862
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Seleniumvivek_prahlad
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin MishraPravin Mishra
 
Tanvir Afzal: Selenium
Tanvir Afzal: SeleniumTanvir Afzal: Selenium
Tanvir Afzal: SeleniumSQABD
 
Selenium by using JAVA
Selenium by using JAVASelenium by using JAVA
Selenium by using JAVAmahirayavarapu
 
white and grey modern website application education project group school pres...
white and grey modern website application education project group school pres...white and grey modern website application education project group school pres...
white and grey modern website application education project group school pres...DreamTheory
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshopcoreyjack
 
Selenium Tutorial
Selenium TutorialSelenium Tutorial
Selenium Tutorialprad_123
 

Semelhante a Automated Web Testing With Selenium (20)

Selenium (1)
Selenium (1)Selenium (1)
Selenium (1)
 
Karate _Framework.ppt
Karate _Framework.pptKarate _Framework.ppt
Karate _Framework.ppt
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering Colleges
 
Selenium
SeleniumSelenium
Selenium
 
Sel
SelSel
Sel
 
Test_Automation using Selenium.ppt
Test_Automation using Selenium.pptTest_Automation using Selenium.ppt
Test_Automation using Selenium.ppt
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Selenium
SeleniumSelenium
Selenium
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin Mishra
 
Selenium
SeleniumSelenium
Selenium
 
Tanvir Afzal: Selenium
Tanvir Afzal: SeleniumTanvir Afzal: Selenium
Tanvir Afzal: Selenium
 
Selenium by using JAVA
Selenium by using JAVASelenium by using JAVA
Selenium by using JAVA
 
selenium
selenium selenium
selenium
 
white and grey modern website application education project group school pres...
white and grey modern website application education project group school pres...white and grey modern website application education project group school pres...
white and grey modern website application education project group school pres...
 
Selenium
SeleniumSelenium
Selenium
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
 
Selenium Tutorial
Selenium TutorialSelenium Tutorial
Selenium Tutorial
 

Último

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Automated Web Testing With Selenium

  • 1. Automated Web Testing with Selenium By Jodie Miners Presented to SBTUG 30 September 2009
  • 2. What is Selenium? It’s Free and Open Source It originally came from Thoughtworks It comes in 3 flavours IDE (Integrated Development Environment) – for recording test cases in Firefox RC (Remote Control) – for running automated tests on any browser Grid – 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 Selenium You are always doing the same steps over and over again You need to get to the last step in a wizard to test that step You want to pre-fill some dummy data Formal Functional and Regression Testing Load Testing *
  • 4. Selenium IDE A Firefox add-on that allows you to record tests for playing back in any browser. Very simple to use Allows non developers to get up and running with automated testing very quickly Then they can pass on to developers for refinement or inclusion into a continuous build system Can extend it easily with a little bit of HTML knowledge
  • 5. Recording and Playback First Decide what you are testing and work out your test case(s) IDE Demo Record a test Play back a test Debug a test Step through a test Capture screen shot Asserts
  • 6. Selenese The language of selenium. It is quite easy to learn 3 parts to it Command – eg Type Locator – eg Input Box Value – eg “ABC” Can easily be written in HTML Things to help build the IDE tests Assert / Wait for Page to Load / Verify Text Present / Verify element present on each page Slow things down with pauses and timeouts Step through firs then run, add pauses and wait’s if it fails because it’s going too fast Add think times
  • 7. Selenese Locators Can Locate page elements by the following 4 methods ID, DOM, Xpath, CSS IDE 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 comprehensive Install Firebug to help with working out the locators
  • 8. Selenium RC Takes a little time and effort to get it up and running Can then run your tests scripts from IDE in different browsers With good results reporting Or write the tests in code and automate the testing even further Issues Need to Install and use Java Very command line / batch file based Selenium RC Demo
  • 9. Demo Run the test in Firefox Run the test in IE Run the test in Chrome Note that they are all in sequence
  • 10. Coding your tests Coding of Selenium testing can be done in Java, Ruby, Groovy, C#, Perl, PHP, Python Most examples are Java or Ruby, not that many people using C# Add If statements Eg if stock exists then add to cart (rather than having an error message) Add looping statements For each product found, add to cart Easier to add parameterisation or data driven tests eg 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 runs Run the test 4 times, each time logged in as a different user Selenium Code Demo with NUnit
  • 11. Demo Show the code Paste the selenese in Show NunitvsMSTest? Run the Nunit test Have one prepared ready to go
  • 12. Reporting There is a great reporting framework if you code in Java or use TestNG Logging Selenium http://loggingselenium.sourceforge.net/ For C# these are the options: Just capture the Selenium output to a file Code a reporting framework yourself Use the Visual Studio Team System Test Edition framework Use the NUnit reporting I use a combination of VSTT reporting and some additional logging to a database that I created myself.
  • 13. Selenium Grid Scale out the tests to run on multiple browsers at the same time Saves time in doing the testing But you need to rely on the reporting as you can’t watch 5+ browsers do the testing Great tutorial and demo here http://selenium-grid.seleniumhq.org/ Requires Java SDK and Apache Ant to run
  • 15. Taking the Grid Further Scale out your grid to the Cloud using Amazon EC2 service Or use a third party service Sauce Labs http://www.saucelabs.com In early beta Uses your own code So can set up the code to either run locally or via web Current special US$100 for 5000 minutes Lots of Browser / OS combinations Test Environment Picture BrowserMobhttp://www.browsermob.com Time consuming to set up Some limitations on which selenium commands can be used Lots of options (eg can test with specific bandwidth limitations) Can be used as for http requests only, as well as real browser tests Around US$2.00 per browser per hour
  • 16. More Advanced Topics UI Element mapping – How developers can make it easier for end users to build Selenium tests using element locator names that they can understand http://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 Testing Purists say Selenium is not for load testing That 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 server Use 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 system It does not do virtual load and virtual users
  • 18. Recording in IE (just for @aussienick) Watin for .net http://watin.sourceforge.net/ Has a built in recorder for IE There 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 Server Looks Fantastic Will also record and play back windows apps Must use TFS
  • 19. References Selenium Tutorial http://dynamitemap.com/selenium/including a good video Full list of software testing tools http://www.softwareqatest.com/qatweb1.html VSTT Quick Reference http://vstt2008qrg.codeplex.com/
  • 20. X-Path References There is a great deal of help online for Xpath, here are some of the best sites I’ve found Xpath reference http://www.w3schools.com/Xpath/default.asp Some nice simple examples (on the Xpath tab) http://confluence.sakaiproject.org/display/QA/Selenium Quick Reference Card http://confluence.sakaiproject.org/display/QA/Selenium MSDN http://msdn.microsoft.com/en-us/library/ms256115.aspx Great tutorial with lots of examples http://www.zvon.org/xxl/XPathTutorial/General/examples.html Selenium Wiki Xpath reference http://wiki.openqa.org/display/SEL/Help+With+XPath