SlideShare a Scribd company logo
1 of 29
Automated Web Testing: Traps for
the Unwary
Simon Stewart, Selenium Project
Simon is best known as the lead of the Selenium
project and is the creator of the WebDriver APIs. He
has been the Tech Lead of Google’s Browser
Infrastructure team and has previously worked at
ThoughtWorks.
He loves code.
www.eurostarconferences.com
Join the conversation on Twitter
#esconfs
@esconfs
@shs96c
www.eurostarconferences.com
Continue the conversation with the speaker on Twitter after the show!
The Three Things You Need to Know
• How to find things
• How to wait for things
• How to keep your code
clean
http://www.flickr.com/photos/hfiguiere/4802869688/
FINDING THINGS
How to Find Things
• Find by
– id
– name
– css selector
– xpath
http://www.flickr.com/photos/icesabre/2142494372/
Why XPath is a Bad Idea
http://www.flickr.com/photos/38194075@N05/4430503343/
And Why It’s Not
http://www.flickr.com/photos/robives/7134916437/
Why CSS Locators are Preferable
• Shared with design and
UX
• Less brittle
http://www.flickr.com/photos/ervega/3662623495/
Using Javascript to Locate Elements
http://www.flickr.com/photos/biker_jun/4138642796/
Custom Bys
• ARIA
• JQuery
WAITING
How a Web App Communicates With
a Server
Other Causes for Delays
• Native events
• window.setTimeout
• Local JS processing
• WebWorkers
Implicit Waiting
Explicit Waits
Wait<X>, FluentWait<X>, WebDriver
Wait
Expected Conditions
Writing New Expected Conditions
• Extend « ExpectedCondition »
• Can be as complex as you like
CLEAN CODE
The DRY Principle
http://www.flickr.com/photos/remibridot/2218573670/
Page Objects: Applying OO and DRY
to Test Code
• Reflect services offered
to users
• Are the only place with
deep knowledge of
page structure
• Can be composed
http://www.flickr.com/photos/dandiffendale/7891256336/
PageFactory
LoadableComponent
SlowLoadableComponent
There Are Other Ways
• Narrative-based
frameworks
• Scenarios and Steps in
BDD
• Custom DSLs
http://www.flickr.com/photos/dolmansaxlil/6779097439/
www.eurostarconferences.com
Questions?
EuroSTAR Webinar Archive
Access almost 50 on-demand software testing webinars by the world's leading
testing experts. Topics include….
www.eurostarconferences.com
Agile, Automation, Test Management, Process Improvements, Risk-based Testing, Performance
Testing, Test Documentation, Cloud Testing, Session-based Testing, Weekend Testers
Visit the archive!
http://www.eurostarconferences.com/community/member/webinar-archive
@esconfs
#esconfs
The EuroSTAR Community.
Are you a member?
Did you know we have an online resource area with almost …
www.eurostarconferences.com
600 software testing presentations, 50 topical
webinars, over 40 videos and podcasts and 20 expert
eBooks
Do you know that membership is completely free and you can access these
premium testing resources anytime?
Join today!
http://www.eurostarconferences.com/community/
member
@esconfs
#esconfs
Call for Submissions to speak at the 2013 EuroSTAR
Conference is now open!
Speak at Europe’s #1 Software Testing Event
Theme: Questioning Testing Deadline for submissions February 13th
For more information http://www.eurostarconferences.com/speakers/conference-2013-call-
for-submissions

More Related Content

More from TEST Huddle

Will Robots Replace Testers?
Will Robots Replace Testers?Will Robots Replace Testers?
Will Robots Replace Testers?TEST Huddle
 
TDD For The Rest Of Us
TDD For The Rest Of UsTDD For The Rest Of Us
TDD For The Rest Of UsTEST Huddle
 
Scaling Agile with LeSS (Large Scale Scrum)
Scaling Agile with LeSS (Large Scale Scrum)Scaling Agile with LeSS (Large Scale Scrum)
Scaling Agile with LeSS (Large Scale Scrum)TEST Huddle
 
Creating Agile Test Strategies for Larger Enterprises
Creating Agile Test Strategies for Larger EnterprisesCreating Agile Test Strategies for Larger Enterprises
Creating Agile Test Strategies for Larger EnterprisesTEST Huddle
 
Is There A Risk?
Is There A Risk?Is There A Risk?
Is There A Risk?TEST Huddle
 
Are Your Tests Well-Travelled? Thoughts About Test Coverage
Are Your Tests Well-Travelled? Thoughts About Test CoverageAre Your Tests Well-Travelled? Thoughts About Test Coverage
Are Your Tests Well-Travelled? Thoughts About Test CoverageTEST Huddle
 
Growing a Company Test Community: Roles and Paths for Testers
Growing a Company Test Community: Roles and Paths for TestersGrowing a Company Test Community: Roles and Paths for Testers
Growing a Company Test Community: Roles and Paths for TestersTEST Huddle
 
Do we need testers on agile teams?
Do we need testers on agile teams?Do we need testers on agile teams?
Do we need testers on agile teams?TEST Huddle
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Testers & Teams on the Agile Fluency™ Journey
Testers & Teams on the Agile Fluency™ Journey Testers & Teams on the Agile Fluency™ Journey
Testers & Teams on the Agile Fluency™ Journey TEST Huddle
 
Practical Test Strategy Using Heuristics
Practical Test Strategy Using HeuristicsPractical Test Strategy Using Heuristics
Practical Test Strategy Using HeuristicsTEST Huddle
 
Thinking Through Your Role
Thinking Through Your RoleThinking Through Your Role
Thinking Through Your RoleTEST Huddle
 
Using Selenium 3 0
Using Selenium 3 0Using Selenium 3 0
Using Selenium 3 0TEST Huddle
 
New Model Testing: A New Test Process and Tool
New Model Testing:  A New Test Process and ToolNew Model Testing:  A New Test Process and Tool
New Model Testing: A New Test Process and ToolTEST Huddle
 
Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk...
 Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk... Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk...
Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk...TEST Huddle
 
Can virtualization transform your API lifecycle?
Can virtualization transform your API lifecycle?Can virtualization transform your API lifecycle?
Can virtualization transform your API lifecycle?TEST Huddle
 
The world class webinar series
The world class webinar seriesThe world class webinar series
The world class webinar seriesTEST Huddle
 
Scrum in Hardware
Scrum in HardwareScrum in Hardware
Scrum in HardwareTEST Huddle
 
How to get Automated Testing "Done"
How to get Automated Testing "Done"How to get Automated Testing "Done"
How to get Automated Testing "Done"TEST Huddle
 
Test process improvement – how hard can it be?
Test process improvement – how hard can it be?Test process improvement – how hard can it be?
Test process improvement – how hard can it be?TEST Huddle
 

More from TEST Huddle (20)

Will Robots Replace Testers?
Will Robots Replace Testers?Will Robots Replace Testers?
Will Robots Replace Testers?
 
TDD For The Rest Of Us
TDD For The Rest Of UsTDD For The Rest Of Us
TDD For The Rest Of Us
 
Scaling Agile with LeSS (Large Scale Scrum)
Scaling Agile with LeSS (Large Scale Scrum)Scaling Agile with LeSS (Large Scale Scrum)
Scaling Agile with LeSS (Large Scale Scrum)
 
Creating Agile Test Strategies for Larger Enterprises
Creating Agile Test Strategies for Larger EnterprisesCreating Agile Test Strategies for Larger Enterprises
Creating Agile Test Strategies for Larger Enterprises
 
Is There A Risk?
Is There A Risk?Is There A Risk?
Is There A Risk?
 
Are Your Tests Well-Travelled? Thoughts About Test Coverage
Are Your Tests Well-Travelled? Thoughts About Test CoverageAre Your Tests Well-Travelled? Thoughts About Test Coverage
Are Your Tests Well-Travelled? Thoughts About Test Coverage
 
Growing a Company Test Community: Roles and Paths for Testers
Growing a Company Test Community: Roles and Paths for TestersGrowing a Company Test Community: Roles and Paths for Testers
Growing a Company Test Community: Roles and Paths for Testers
 
Do we need testers on agile teams?
Do we need testers on agile teams?Do we need testers on agile teams?
Do we need testers on agile teams?
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Testers & Teams on the Agile Fluency™ Journey
Testers & Teams on the Agile Fluency™ Journey Testers & Teams on the Agile Fluency™ Journey
Testers & Teams on the Agile Fluency™ Journey
 
Practical Test Strategy Using Heuristics
Practical Test Strategy Using HeuristicsPractical Test Strategy Using Heuristics
Practical Test Strategy Using Heuristics
 
Thinking Through Your Role
Thinking Through Your RoleThinking Through Your Role
Thinking Through Your Role
 
Using Selenium 3 0
Using Selenium 3 0Using Selenium 3 0
Using Selenium 3 0
 
New Model Testing: A New Test Process and Tool
New Model Testing:  A New Test Process and ToolNew Model Testing:  A New Test Process and Tool
New Model Testing: A New Test Process and Tool
 
Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk...
 Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk... Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk...
Five Digital Age Trends That Will Dramatically Impact Testing And Quality Sk...
 
Can virtualization transform your API lifecycle?
Can virtualization transform your API lifecycle?Can virtualization transform your API lifecycle?
Can virtualization transform your API lifecycle?
 
The world class webinar series
The world class webinar seriesThe world class webinar series
The world class webinar series
 
Scrum in Hardware
Scrum in HardwareScrum in Hardware
Scrum in Hardware
 
How to get Automated Testing "Done"
How to get Automated Testing "Done"How to get Automated Testing "Done"
How to get Automated Testing "Done"
 
Test process improvement – how hard can it be?
Test process improvement – how hard can it be?Test process improvement – how hard can it be?
Test process improvement – how hard can it be?
 

Recently uploaded

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Recently uploaded (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

'Automated Web Testing: Traps for the Unwary' by Simon stewart

  • 1. Automated Web Testing: Traps for the Unwary Simon Stewart, Selenium Project Simon is best known as the lead of the Selenium project and is the creator of the WebDriver APIs. He has been the Tech Lead of Google’s Browser Infrastructure team and has previously worked at ThoughtWorks. He loves code. www.eurostarconferences.com
  • 2. Join the conversation on Twitter #esconfs @esconfs @shs96c www.eurostarconferences.com Continue the conversation with the speaker on Twitter after the show!
  • 3. The Three Things You Need to Know • How to find things • How to wait for things • How to keep your code clean http://www.flickr.com/photos/hfiguiere/4802869688/
  • 5. How to Find Things • Find by – id – name – css selector – xpath http://www.flickr.com/photos/icesabre/2142494372/
  • 6. Why XPath is a Bad Idea http://www.flickr.com/photos/38194075@N05/4430503343/
  • 7. And Why It’s Not http://www.flickr.com/photos/robives/7134916437/
  • 8. Why CSS Locators are Preferable • Shared with design and UX • Less brittle http://www.flickr.com/photos/ervega/3662623495/
  • 9. Using Javascript to Locate Elements http://www.flickr.com/photos/biker_jun/4138642796/
  • 12. How a Web App Communicates With a Server
  • 13. Other Causes for Delays • Native events • window.setTimeout • Local JS processing • WebWorkers
  • 18. Writing New Expected Conditions • Extend « ExpectedCondition » • Can be as complex as you like
  • 21. Page Objects: Applying OO and DRY to Test Code • Reflect services offered to users • Are the only place with deep knowledge of page structure • Can be composed http://www.flickr.com/photos/dandiffendale/7891256336/
  • 25. There Are Other Ways • Narrative-based frameworks • Scenarios and Steps in BDD • Custom DSLs http://www.flickr.com/photos/dolmansaxlil/6779097439/
  • 27. EuroSTAR Webinar Archive Access almost 50 on-demand software testing webinars by the world's leading testing experts. Topics include…. www.eurostarconferences.com Agile, Automation, Test Management, Process Improvements, Risk-based Testing, Performance Testing, Test Documentation, Cloud Testing, Session-based Testing, Weekend Testers Visit the archive! http://www.eurostarconferences.com/community/member/webinar-archive @esconfs #esconfs
  • 28. The EuroSTAR Community. Are you a member? Did you know we have an online resource area with almost … www.eurostarconferences.com 600 software testing presentations, 50 topical webinars, over 40 videos and podcasts and 20 expert eBooks Do you know that membership is completely free and you can access these premium testing resources anytime? Join today! http://www.eurostarconferences.com/community/ member @esconfs #esconfs
  • 29. Call for Submissions to speak at the 2013 EuroSTAR Conference is now open! Speak at Europe’s #1 Software Testing Event Theme: Questioning Testing Deadline for submissions February 13th For more information http://www.eurostarconferences.com/speakers/conference-2013-call- for-submissions

Editor's Notes

  1. There are other mechanisms (such as link text), but we’ll not be paying attention to them for now.Note that although ids should be unique they very seldom are.
  2. Three main reasons. it can be very brittle as the tools used to create them automatically tie the expression very closely to the page: it won’t survive a refactoring.Xpath engines work at different speeds. On IE there isn’t one available for an HTML DOM, so we use one written in JS, but JS on IE is slower than on any other browserDifferent browsers interpret HTML differently. The page structure may well be different in different browsers
  3. Best way to find a parent node (“..”)Can be a useful way of narrowing down a subset of the DOM (eg: finding all TR elements when there are nested tables)
  4. Whereas Xpath tends to only be used by testers, CSS selectors are often shared with UX and/or designers. They are less brittleSelectors located by machine tend to be far less brittle
  5. What if you’re using JQuery?Also a really good way to implement “Gray Box” testing: have the app provide useful JS functions to grab bits of the UI. Gmonkey in Gmail provides access to key parts of the UI in this way.
  6. Demo implmentation
  7. Watch out for the StaleElementReferenceException