16
Ept Computing | www.eptcomputing.com Selenium in real world projects Automated testing of web applications Martin Kleppmann

Selenium in real-world projects: Automated testing for web applications

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

Page 1: Selenium in real-world projects: Automated testing for web applications

Ept Computing | www.eptcomputing.com

Selenium in real world projects

Automated testing of web applications

Martin Kleppmann

Page 2: Selenium in real-world projects: Automated testing for web applications

Deploying anew release

http://flickr.com/photos/josa/124264708/ (creative commons)

Page 3: Selenium in real-world projects: Automated testing for web applications

http://flickr.com/photos/dennissylvesterhurd/200001422/ (creative commons)

Page 4: Selenium in real-world projects: Automated testing for web applications

Selenium

Page 5: Selenium in real-world projects: Automated testing for web applications
Page 6: Selenium in real-world projects: Automated testing for web applications
Page 7: Selenium in real-world projects: Automated testing for web applications
Page 8: Selenium in real-world projects: Automated testing for web applications

Unit testing

Model-View-Controller

Controller

View

Model DB

Request

Response

Client

Page 9: Selenium in real-world projects: Automated testing for web applications

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

Page 10: Selenium in real-world projects: Automated testing for web applications

wget -r

Unit testingController

View

Model DB

Request

Response

Client

Model-View-Controller

Seleniumtesting

Page 11: Selenium in real-world projects: Automated testing for web applications

Functional stack

Rendering on screen

DOM (Document tree)

HTML

HTTP

Web framework

Database

Selenium

wget -r

Model test

Page 12: Selenium in real-world projects: Automated testing for web applications

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"

Page 13: Selenium in real-world projects: Automated testing for web applications

Demo

Page 14: Selenium in real-world projects: Automated testing for web applications

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

Page 15: Selenium in real-world projects: Automated testing for web applications

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

Page 16: Selenium in real-world projects: Automated testing for web applications

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...