Académique Documents
Professionnel Documents
Culture Documents
ThoughtWorks ®
nford@thoughtworks.com
3003 Summit Boulevard, Atlanta, GA 30319
www.nealford.com
www.thoughtworks.com
blog: memeagora.blogspot.com
twitter: neal4d
Questions, Slides, and Samples
Selenium’s scope
TestRunner techniques
Remote Control
Ajax
IDE
Extensions
Best practices
Selenium’s Scope
Selenium is an acceptance testing tool for
web applications
Selenium Core
Selenium Test
Runner Application
Under Test
The Selenium IDE
FireFox extension
Not just a recorder
Intelligent field selection
Autocomplete for all
common Selenium
commands
Walk through tests
Debug and set
breakpoints
String Matching Patterns
glob:pattern
Match a string against a "glob" (aka "wildmat") pattern.
"*" represents any sequence of characters
"?" 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.
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.
=> End 2 End Test
TestRunner Techniques
End-to-end Testing
assertElementNotPresent //table[@id='mytable']/tr[11]
storeAttribute
(elementLocator@attributeName,
variableName)
Stores the value of an element attribute into a
variable.
Variable Substitution
Provides a simple way to access variables
using ${xxx} syntax
JavaScript Evaluation
You can use JavaScript to construct
whatever values you want
Selenium Core
JUnit
Proxy Server
Test Application
Under Test
Interactive Selenium
Start the proxy
Create an instance of the browser
The proxy will provide a unique ID that must be
used in all subsequent commands
You’ll see a separate instance of the browser
launch
Issue Selenium commands
When done, kill the browser instance
=> Interactive Selenium
Test Code Reuse
One of the advantages of remote control
Refactor frequently
Multiple Language Support
The Selenium IDE generates tests in a
variety of languages
All your tests don’t have to be in the same
language
Java == Ruby example =>
Selenium Remote Control, Selenium Remote
Control Ruby
Use the language that makes sense for the
situation
Decisions
TestRunner tests can’t make deciscions
The Selenium language was designed to be
strictly declarative, not imperative
In remote control, you write unit tests
Allows you to make testing decisions
Firefox makes you logon, IE doesn’t
Different roles for different users
Remote control gives you imperative tests
in Selenium
=> Decision Demo
The Selenium IDE
More than just a pretty face!
Supports multiple languages
TestRunner (declarative)
Java, Ruby, C#, Python, etc. (imperative)
A round-trip tool…
…but only for declarative tests
Don’t make the imperative plunge lightly
Ajax
Because Selenium works directly with the
DOM, testing Ajax is easy
Testing XmlHttpRequest =>
Testing collapsable divs => End 2 End Test
Testing absence of controls =>
Extending Selenium
Selenium allows you to add your own
actions, checks, and locator strategies
ThoughtWorks
14 Wall St, Suite 2019, New York, NY 10005