no forget about that
LETS JUST WRITE A TEST
Now: Record and Playback
• Intelligent ﬁeld selection will use IDs, names, or
XPath as needed
• Autocomplete for all common Selenium
• Walk through tests
• Debug and set breakpoints
• Save tests as HTML, Ruby scripts, or any other
Totally takes 5 seconds, man
opens a page using a URL.
performs a click operation, and
optionally waits for a new page to
verifies an expected page title.
verifies expected text is
somewhere on the page.
VERIFY PAGE ELEMENTS
1. an element is present somewhere on the page?
2. speciﬁc text is somewhere on the page?
3. speciﬁc text is at a speciﬁc location on the page?
• clickAndWait is usually
• type usually requires you
to click somewhere else ﬁrst
• it’s slow
• brittle if the UI is changing
HARD PART’S JUST FINDING IT
Good thing you have so many options ...
• ﬁnd elements by name
• ﬁnd them by id if they have it
• or with CSS selectors if you understand the cascade
• Xpath is like a buzzsaw (a little more expensive)
• link text as a last resort (since it changes often)
is not the same as
Selenium-RC leverages the full power of
programming languages, creating tests that
can do things like
• read and write external ﬁles,
• make queries to a database,
• send emails with test reports
anything else a user can do
with a normal application ...
RC can where IDE can’t
• condition statements
• logging and reporting of test results
• error handling, particularly unexpected errors
• database testing
• test case grouping
• re-execution of failed tests
• test case dependency
• capture screenshots on test failures
WAIT, WHAT ABOUT TEST-
If you click around the app to build a test,
that can’t be testing before development.
You actually should write them beforehand, by hand, just like
you would unit tests. It’s not so scary.
• NUnit for C#
• Junit for Java
• Selenium gem for Ruby
Put it on your SVN server
trigger it with SVN hooks
with Selenium and Criuse Control
WHAT IT MEANS
• Run your unit tests ﬁrst locally (because they’re fast).
• Checking in your changes triggers the continuous
integration server running your Selenium tests (slow
because they are in the browser).
• Cruise Control gives you a web-based heads up when you
fail or pass tests.
User Experience @ Meedan.net