This document discusses strategies for making Selenium web application GUI tests less brittle. It recommends writing fewer GUI tests and more unit and integration tests. For the GUI tests that are written, it suggests hand coding the tests in Java rather than recording and playback, using object oriented design principles, keeping test framework code dry while allowing test code to be wetter, and using element locators like ID attributes and xpath as a last resort. The document then provides examples of code that implements these strategies.
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
Why Your Selenium Tests are So Brittle and How to Fix It
1. Why Your Se Tests are
So Dang Brittle…
…and what to do about it
Patrick Wilson-Welsh
pwelsh@pillartechnology.com
2. Introduction
Patrick Welsh
Senior Agile Consultant
Pillar Technology Group
http://pillartechnology.com
pwelsh@pillartechnology.com
http://patrickwilsonwelsh.com
http://coderetreat.ning.com/
mobile: 248 565 6130
twitter: patrickwelsh
3. Caveat Lector:
This is a technical webinar.
To follow, you’ll need to know Selenium,
a bit of Java, xpath, HTML,
and a bit of Object Oriented Design.
And, I will be gentle.
7. Number #1 Reason Selenium RC, through
the web app GUI tests are so brittle?
8. Because you are writing
too many of them.
Let me put that another way.
9. You are committing too high a percentage
of total test-automation and
programming resources to
that specific kind
of automated testing.
Have a plan for outgrowing that pattern.
Actually, have a fairy tale:
23. Automated testing is everybody’s job.
Se tests are written by testers and
programmers together. Period.
The whole team shares sufficient testing as
part of Definition of Done.
24. • Use Se only for what it‟s good for
• Never record and play back tests
• Se IDE is just a sandbox. Not an IDE.
• Hand-roll your tests (I use Java)
• Use a bit of Object Oriented Design
• Separate test code from framework code
25. • Test classes get common setup
• Keep test framework code really DRY
• Beware test code that is too DRY
• Duplication is built into GUI test code
• Test-class page flows: “open-coded”
• Don‟t fret so much about encapsulation.
• Concentrate on test clarity.
26. • Use id or name attributes if you got „em
• Use xpath as a last-resort element locator
• Use least-brittle xpath patterns
• Know the IE xpath pitfalls
• Beware of Firebug-Driven Development
• Use Singleton Se instance
• Use Singleton/static app state, carefully
• Consider a PageFlowSequence pattern
27. A principle to consider for Se testing:
DRY test framework; “wet” test code.
30. Our Next Steps
• Upcoming Webinars: Please visit pillartechnology.com/events
• All of the webinar content is available to your business in a 1-2 day on-site workshop
or as a “lunch and learn” format. Please contact us for details.
• Visit www.pillartechnology.com/events to access presentation slides and full archived
broadcasts of past webinars.
• Twitter.com/agilesoftware
• Blog: www.pillartechnology.com/blog
• LinkedIn: Join the Agile Enthusiast Group on LinkedIn: http://bit.ly/agilegroup
• YouTube: http://www.youtube.com/user/PillarTechnology
• Phone: (888) 3-pillar
• Web: pillartechnology.com
• Email: info@pillartechnology.com