SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Lets Automate!
Lets Automate your web tests using Selenium
A guide to automation using selenium
Ahmed Mubbashir Khan, http://about.me/mubbashir
@mubbashir
Agenda
Demo of sikuli-on-selenium
Automation
Automation objective
What is selenium
-Components of selenium
-Walkthrough
- S-IDE
- Driver/RC
-Grid
-Walking through the code of the demo(Maven, Java, TestNG)
Command Reference
- Locators Reference
Test automation is any use of tools to aid
testing- James Bach (http://www.satisfice.com/blog/archives/118)
OK- But its a very broad term, what are we
going to automate?
Answer: Regression Tests (Checks to be
precise)
http://www.developsense.com/blog/2009/08/testing-vs-checking/
What is Test/Check Automation?
Expecting automation to find lots of bugs when
you are automating regression testing is the
wrong objective - Dorothy Graham (STAReast 19 April, 2012)
Automation is not a magic tool. It will not find
bugs - good tests finds the bugs - Dorothy
Graham (STAReast 19 April, 2012)
What is the objective of (Regression)
Automation?
Think of your automation as a baseline test
suite to be used in conjunction with manual
testing, rather than as a replacement for it-
James Bach (http://www.satisfice.com/articles/test_automation_snake_oil.pdf (1999))
Just as there can be quality
software, there can be quality test automation-
James Bach (http://www.satisfice.com/articles/test_automation_snake_oil.pdf (1999))
What is the objective of (Regression)
Automation??
Test Automation is a software Project, Treat it
as a software project.
Test Automation is coding, why would you ask
it to be done by someone who can't code-
Adam Goucher
Automation is Software.
• Rapid feedback to developers
• Virtually unlimited iterations of test case
execution
• Support for Agile and extreme development
methodologies
• Disciplined documentation of test cases
• Customized defect reporting
• Finding defects missed by manual testing
Why Not Automate? Which are Myths? and
what about ROI?
To Automate or Not to Automate?
Hmm..
Always Remember: Agile test quadrant
Selenium (set of libraries) automates browsers.
That's it. What you do with that power is entirely
up to you. (http://seleniumhq.org/)
Selenium's History...
What is selenium?
Its Opensource (code.google.com/p/selenium/)
It runs in many browsers and operating
systems
Can be controlled by many programming
languages and testing frameworks.
Companies using selenium includes Google,
BBC, Ubuntu, Pivotal Labs, Mozlilla and Yelp
among many others.
And "Die QTP Die" http://paulhammant.
Why selenium?
QTP vs Selenium- Job Market
Why selenium??
Selenium does not own the browser, OS does.
Selenium can interact with the rendered HTML content of a
given web page, but it cannot interact with native browser
operations
● Anything which is outside web app (e.g.
upload/download dialog box)
● Anything which runs in a different runtime (e.g flash,
java applets)
● Some HTML5 features (e.g. video, audio, canvas,
webGL)
What selenium can't do?
Selenium is not a testing framework.
Selenium allows you to interact with web pages but
creating tests on top of it is the reponsibility of Test
Framework (xUnit) (https://twitter.com/#!
/AutomatedTester/status/176830982316494849)
What selenium can't do?
Download: http://code.google.
com/p/selenium/downloads/list
IDE, IDE Walkthrough
Lets do it
What else?
Driver(s)
Grid
Installation
Driver(s)
Grid:
java -jar selenium-server-standalone-*.jar -role hub
java -jar selenium-server-standalone-*.jar -port 5456 -role
node -hub http://192.168.0.92:4444/grid/register -browser
browserName=firefox,maxInstances=3 -hubHost
"192.168.0.92" -host "192.168.0.92"
gem install selenium-webdriver
[1] pry(main)> require 'selenium-webdriver'
[2] pry(main)> driver = Selenium::WebDriver.for :firefox
driver=Selenium::WebDriver.for(:remote,:url => "http://192.
168.0.94:4444/wd/hub/",:desired_capabilities => caps)
Installation
Driver(s)
from selenium import webdriver
driver = webdriver.Chrome
('/Users/mubbashir/Documents/Frameworks/selenium/chor
me_driver/chromedriver')
driver.get("http://google.com")
driver.quit()
Installation
Recording
Adding waits and assertions
Replay and Verify
Don't record and save instead record and
export
Page Objetcs
IDE- Writing Test Case
Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
Commonly used commands:
open
click/clickAndWait
verifyTitle/assertTitle
verifyTextPresent
verifyElementPresent
verifyText
verifyTable
xxAndWait
waitForXX
IDE- Command Reference
Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
To Execute these commands you need to know:
Element Locators
Element Filters
String-match Patterns
IDE- Command Reference
Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
Element Locators
● identifier=id: Select the element with the specified @id attribute. If no match is found, select the
first element whose @name attribute is id. (This is normally the default; see below.)
● id=id: Select the element with the specified @id attribute.
● name=name: Select the first element with the specified @name attribute.
○ username
○ name=username
● The name may optionally be followed by one or more element-filters, separated from the name
by whitespace. If the filterType is not specified, value is assumed.
○ name=flavour value=chocolate
● dom=javascriptExpression: Find an element by evaluating the specified string. This allows you
to traverse the HTML Document Object Model using JavaScript. Note that you must not return a
value in this string; simply make it the last expression in the block.
○ dom=document.forms['myForm'].myDropdown
○ dom=document.images[56]
○ dom=function foo() { return document.links[1]; }; foo();
IDE- Command Reference-Locators
Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
Element Locators
● xpath=xpathExpression: Locate an element using an XPath expression.
○ xpath=//img[@alt='The image alt text']
○ xpath=//table[@id='table1']//tr[4]/td[2]
○ xpath=//a[contains(@href,'#id1')]/@class
○ xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
○ xpath=//input[@name='name2' and @value='yes']
○ xpath=//*[text()="right"]
● link=textPattern: Select the link (anchor) element which contains text matching the specified
pattern.
○ link=The link text
● css=cssSelectorSyntax: Select the element using css selectors. Please refer to CSS2 selectors,
CSS3 selectors for more information..
○ css=a[href="#id3"]
○ css=span#firstChild + span
IDE- Command Reference-Locators
Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
String-match Patterns
● glob:pattern: Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a kind of limited
regular-expression syntax typically used in command-line shells. In a glob pattern, "*" represents
any sequence of characters, and "?" represents any single character. Glob patterns match
against the entire string.
● regexp:regexp: Match a string using a regular-expression. The full power of JavaScript regular-
expressions is available.
● regexpi:regexpi: Match a string using a case-insensitive regular-expression.
● exact:string: Match a string exactly, verbatim, without any of that fancy wildcard stuff.
If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern
IDE- Command Reference- String
match patterns
Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference.
html#actions)
Commonly used commands:
assertFoo(pattern)
assertFooPresent
assertFooNotPresent
Alerts, Popups, and Multiple
Windows

Contenu connexe

Tendances

Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentYao Nien Chung
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Iakiv Kramarenko
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...Edureka!
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Applitools
 
Test automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinTest automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinOren Rubin
 
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App Yao Nien Chung
 
From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.David Aguilera
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in YiiIlPeach
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react formYao Nien Chung
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutionsArtem Nagornyi
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnetVlad Maniak
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JSMichael Haberman
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answerskavinilavuG
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXAlex Ruiz
 
Selenium Interview Questions & Answers
Selenium Interview Questions & AnswersSelenium Interview Questions & Answers
Selenium Interview Questions & AnswersTechcanvass
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Practical Test Automation Deep Dive
Practical Test Automation Deep DivePractical Test Automation Deep Dive
Practical Test Automation Deep DiveAlan Richardson
 

Tendances (20)

Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
 
Test automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubinTest automation & Seleniun by oren rubin
Test automation & Seleniun by oren rubin
 
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App
 
Gems Of Selenium
Gems Of SeleniumGems Of Selenium
Gems Of Selenium
 
From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in Yii
 
Foundation selenium java
Foundation selenium java Foundation selenium java
Foundation selenium java
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutions
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
My Test Automation Journey
My Test Automation JourneyMy Test Automation Journey
My Test Automation Journey
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFX
 
Selenium Interview Questions & Answers
Selenium Interview Questions & AnswersSelenium Interview Questions & Answers
Selenium Interview Questions & Answers
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Practical Test Automation Deep Dive
Practical Test Automation Deep DivePractical Test Automation Deep Dive
Practical Test Automation Deep Dive
 

Similaire à Introduction to Selenium and Test Automation

Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
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
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011Yuriy Gerasimov
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Seleniumrohitnayak
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium Zoe Gilbert
 
A Sampling of Tools
A Sampling of ToolsA Sampling of Tools
A Sampling of ToolsDawn Code
 
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
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaAgile Testing Alliance
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotLearning Slot
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshersNaga Mani
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ideTestertester Jaipur
 
Selenium Webdriver Interview Questions
Selenium Webdriver Interview QuestionsSelenium Webdriver Interview Questions
Selenium Webdriver Interview QuestionsJai Singh
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presentedVijayan Reddy
 

Similaire à Introduction to Selenium and Test Automation (20)

Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
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)
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Selenium
SeleniumSelenium
Selenium
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Selenium
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
A Sampling of Tools
A Sampling of ToolsA Sampling of Tools
A Sampling of Tools
 
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!
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
Web Testen mit Selenium
Web Testen mit SeleniumWeb Testen mit Selenium
Web Testen mit Selenium
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ide
 
Selenium Webdriver Interview Questions
Selenium Webdriver Interview QuestionsSelenium Webdriver Interview Questions
Selenium Webdriver Interview Questions
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 

Dernier

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Dernier (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Introduction to Selenium and Test Automation

  • 1. Lets Automate! Lets Automate your web tests using Selenium A guide to automation using selenium Ahmed Mubbashir Khan, http://about.me/mubbashir @mubbashir
  • 2. Agenda Demo of sikuli-on-selenium Automation Automation objective What is selenium -Components of selenium -Walkthrough - S-IDE - Driver/RC -Grid -Walking through the code of the demo(Maven, Java, TestNG) Command Reference - Locators Reference
  • 3. Test automation is any use of tools to aid testing- James Bach (http://www.satisfice.com/blog/archives/118) OK- But its a very broad term, what are we going to automate? Answer: Regression Tests (Checks to be precise) http://www.developsense.com/blog/2009/08/testing-vs-checking/ What is Test/Check Automation?
  • 4. Expecting automation to find lots of bugs when you are automating regression testing is the wrong objective - Dorothy Graham (STAReast 19 April, 2012) Automation is not a magic tool. It will not find bugs - good tests finds the bugs - Dorothy Graham (STAReast 19 April, 2012) What is the objective of (Regression) Automation?
  • 5. Think of your automation as a baseline test suite to be used in conjunction with manual testing, rather than as a replacement for it- James Bach (http://www.satisfice.com/articles/test_automation_snake_oil.pdf (1999)) Just as there can be quality software, there can be quality test automation- James Bach (http://www.satisfice.com/articles/test_automation_snake_oil.pdf (1999)) What is the objective of (Regression) Automation??
  • 6. Test Automation is a software Project, Treat it as a software project. Test Automation is coding, why would you ask it to be done by someone who can't code- Adam Goucher Automation is Software.
  • 7. • Rapid feedback to developers • Virtually unlimited iterations of test case execution • Support for Agile and extreme development methodologies • Disciplined documentation of test cases • Customized defect reporting • Finding defects missed by manual testing Why Not Automate? Which are Myths? and what about ROI? To Automate or Not to Automate?
  • 9. Selenium (set of libraries) automates browsers. That's it. What you do with that power is entirely up to you. (http://seleniumhq.org/) Selenium's History... What is selenium?
  • 10. Its Opensource (code.google.com/p/selenium/) It runs in many browsers and operating systems Can be controlled by many programming languages and testing frameworks. Companies using selenium includes Google, BBC, Ubuntu, Pivotal Labs, Mozlilla and Yelp among many others. And "Die QTP Die" http://paulhammant. Why selenium?
  • 11. QTP vs Selenium- Job Market Why selenium??
  • 12. Selenium does not own the browser, OS does. Selenium can interact with the rendered HTML content of a given web page, but it cannot interact with native browser operations ● Anything which is outside web app (e.g. upload/download dialog box) ● Anything which runs in a different runtime (e.g flash, java applets) ● Some HTML5 features (e.g. video, audio, canvas, webGL) What selenium can't do?
  • 13. Selenium is not a testing framework. Selenium allows you to interact with web pages but creating tests on top of it is the reponsibility of Test Framework (xUnit) (https://twitter.com/#! /AutomatedTester/status/176830982316494849) What selenium can't do?
  • 14. Download: http://code.google. com/p/selenium/downloads/list IDE, IDE Walkthrough Lets do it What else? Driver(s) Grid Installation
  • 15. Driver(s) Grid: java -jar selenium-server-standalone-*.jar -role hub java -jar selenium-server-standalone-*.jar -port 5456 -role node -hub http://192.168.0.92:4444/grid/register -browser browserName=firefox,maxInstances=3 -hubHost "192.168.0.92" -host "192.168.0.92" gem install selenium-webdriver [1] pry(main)> require 'selenium-webdriver' [2] pry(main)> driver = Selenium::WebDriver.for :firefox driver=Selenium::WebDriver.for(:remote,:url => "http://192. 168.0.94:4444/wd/hub/",:desired_capabilities => caps) Installation
  • 16. Driver(s) from selenium import webdriver driver = webdriver.Chrome ('/Users/mubbashir/Documents/Frameworks/selenium/chor me_driver/chromedriver') driver.get("http://google.com") driver.quit() Installation
  • 17. Recording Adding waits and assertions Replay and Verify Don't record and save instead record and export Page Objetcs IDE- Writing Test Case
  • 18. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference. html#actions) Commonly used commands: open click/clickAndWait verifyTitle/assertTitle verifyTextPresent verifyElementPresent verifyText verifyTable xxAndWait waitForXX IDE- Command Reference
  • 19. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference. html#actions) To Execute these commands you need to know: Element Locators Element Filters String-match Patterns IDE- Command Reference
  • 20. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference. html#actions) Element Locators ● identifier=id: Select the element with the specified @id attribute. If no match is found, select the first element whose @name attribute is id. (This is normally the default; see below.) ● id=id: Select the element with the specified @id attribute. ● name=name: Select the first element with the specified @name attribute. ○ username ○ name=username ● The name may optionally be followed by one or more element-filters, separated from the name by whitespace. If the filterType is not specified, value is assumed. ○ name=flavour value=chocolate ● dom=javascriptExpression: Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block. ○ dom=document.forms['myForm'].myDropdown ○ dom=document.images[56] ○ dom=function foo() { return document.links[1]; }; foo(); IDE- Command Reference-Locators
  • 21. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference. html#actions) Element Locators ● xpath=xpathExpression: Locate an element using an XPath expression. ○ xpath=//img[@alt='The image alt text'] ○ xpath=//table[@id='table1']//tr[4]/td[2] ○ xpath=//a[contains(@href,'#id1')]/@class ○ xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td ○ xpath=//input[@name='name2' and @value='yes'] ○ xpath=//*[text()="right"] ● link=textPattern: Select the link (anchor) element which contains text matching the specified pattern. ○ link=The link text ● css=cssSelectorSyntax: Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information.. ○ css=a[href="#id3"] ○ css=span#firstChild + span IDE- Command Reference-Locators
  • 22. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference. html#actions) String-match Patterns ● glob:pattern: Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a kind of limited regular-expression syntax typically used in command-line shells. In a glob pattern, "*" represents any sequence of characters, and "?" represents any single character. Glob patterns match against the entire string. ● regexp:regexp: Match a string using a regular-expression. The full power of JavaScript regular- expressions is available. ● regexpi:regexpi: Match a string using a case-insensitive regular-expression. ● exact:string: Match a string exactly, verbatim, without any of that fancy wildcard stuff. If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern IDE- Command Reference- String match patterns
  • 23. Actions/Commands (http://release.seleniumhq.org/selenium-core/1.0.1/reference. html#actions) Commonly used commands: assertFoo(pattern) assertFooPresent assertFooNotPresent Alerts, Popups, and Multiple Windows