Upload
martin-kleppmann
View
7.007
Download
2
Embed Size (px)
DESCRIPTION
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.
Citation preview
Ept Computing | www.eptcomputing.com
Selenium in real world projects
Automated testing of web applications
Martin Kleppmann
Deploying anew release
http://flickr.com/photos/josa/124264708/ (creative commons)
http://flickr.com/photos/dennissylvesterhurd/200001422/ (creative commons)
Selenium
Unit testing
Model-View-Controller
Controller
View
Model DB
Request
Response
Client
Build cycle
Deploy to staging server
Migrate staging database
Fill database with example data
Run Selenium scripts
Run unit/model tests
Checkout latest version
Notify us of outcome
10 m
ins
Render lots of views: wget -r
wget -r
Unit testingController
View
Model DB
Request
Response
Client
Model-View-Controller
Seleniumtesting
Functional stack
Rendering on screen
DOM (Document tree)
HTML
HTTP
Web framework
Database
Selenium
wget -r
Model test
Sample script# User is not logged in. Searches for auction and chooses it in the listingselenium.type "search_query", "selenium"selenium.click "commit"
selenium.click "link=Selenium test auction, single lot, normal+buy now"
# User places a bid of 12 pounds (below the reserve price)selenium.type "bid_max_price_vatted", "12"selenium.click "bid_submit"
# User logs in as Adalbertselenium.type "login", "adalbert"selenium.type "password", "asdf"selenium.click "commit"
# Bid confirmation pageselenium.click "bid_submit"
# Redirected to auction page - check Adalbert is losingassert selenium.is_text_present("You are losing your bid on this auction")assert selenium.is_text_present("below the seller's reserve price")
selenium.wait_for_page_to_load "30000"
selenium.wait_for_page_to_load "30000"
selenium.wait_for_page_to_load "30000"
selenium.wait_for_page_to_load "30000"
selenium.wait_for_page_to_load "30000"
Demo
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
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
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...