Selenium (http://selenium.openqa.org/) is a tool which allows web developers to run automatic functional tests on their applications. This presentation gives motivation for automated regression testing of web applications, and shows how Selenium can be integrated into a continuous build process.
9. Build cycle
Checkout latest version
Run unit/model tests
Migrate staging database
10 mins
Deploy to staging server
Fill database with example data
Render lots of views: wget -r
Run Selenium scripts
Notify us of outcome
11. Functional stack
Rendering on screen
DOM (Document tree) Selenium
HTML
wget -r
HTTP
Web framework Model test
Database
12. Sample script
# User is not logged in. Searches for auction and chooses it in the listing
selenium.type quot;search_queryquot;, quot;seleniumquot;
selenium.click quot;commitquot;
selenium.wait_for_page_to_load quot;30000quot;
selenium.click quot;link=Selenium test auction, single lot, normal+buy nowquot;
selenium.wait_for_page_to_load quot;30000quot;
# User places a bid of 12 pounds (below the reserve price)
selenium.type quot;bid_max_price_vattedquot;, quot;12quot;
selenium.click quot;bid_submitquot;
selenium.wait_for_page_to_load quot;30000quot;
# User logs in as Adalbert
selenium.type quot;loginquot;, quot;adalbertquot;
selenium.type quot;passwordquot;, quot;asdfquot;
selenium.click quot;commitquot;
selenium.wait_for_page_to_load quot;30000quot;
# Bid confirmation page
selenium.click quot;bid_submitquot;
selenium.wait_for_page_to_load quot;30000quot;
# Redirected to auction page - check Adalbert is losing
assert selenium.is_text_present(quot;You are losing your bid on this auctionquot;)
assert selenium.is_text_present(quot;below the seller's reserve pricequot;)
14. Selenium strong points
• Simple and powerful DOM-level testing
• Fairly stable – ok for continuous integration
• Ajax-heavy apps (cross-browser issues)
• Testing typical user flows
• Good fit with Agile et al.
• Open Source
15. Selenium weak points
• Fiddly setup, platform maintenance
• Tedious error diagnosis
• Valid UI changes may break test
• Rendering tests limited
• Interaction with Flash
• Slow; concurrency problematic
• Heavily dependent on state – generate data
16. The future
• “Selenium on demand” service – “rent a
web browser”, large choice of platforms
• Acceptance testing; testing impact of ads
• Memory leak detection
• Access to email in tests
• etc...