Optimizing Selenium for build performance
Tricks and tips for creating a fast and scalable test codebase
Intro
Santiago Suarez Ordoñez
>5 years with Selenium and test automation
Selenium committer
Sauce Ninja at Sauce Labs
Sauce Labs
Agenda
The main secret to faster Selenium tests
Parallelization
Hardware == cheap
Engineers == $$$$
Paralellization is not easy
It takes some work to get there...
Don't DDOS Your Server
Serial tests == very low load
50 concurrent browsers == lots of requests
Pay attention and when needed, get a web server that better resembles production
Data Independence
Execution order => Data dependency
Parallel tests == no order
Never use data sets more than once!
Wipe your DB on every build
Data Dependency
Data Collision
Atomic Tests
TestSignupLoginChangePasswdLogout :,(
Small tests:
Small tests are good tests
Focus on the Essential
Don't test content during functional tests
Write integrity tests
Avoid Selenium for plain content when possible
Don't test performance during functional tests
Write performance tests
Test performance in a controlled environment
Generate Application State
Generate state out of the browser
The UI is inefficient
Causes interdependence (Y can't run unless X works)
Keep manual versions for special cases
Generate State via DB/Memcache
Generate State via Web Server
Use Guinea Pigs
Test widgets in isolation
Test extensively on an empty page
Run smoke tests on any real page
Guinea Pig Example
Remove Third Party Where Possible
Anything outside your control slows you down Adds non-determinism (brittleness)
Test third party with specific third party tests
Run functional tests including third party on a separate schedule
Get Rid of all Static Pauses
Every pause is there for a purpose
Find that purpose and wait smartly
Every second spent waiting for something that already happened, is a second wasted by your full development team
Break Your Build in Test Steps
Not all tests are worth parallelizing :,(
Doesn't mean all of them need to go serially
Have a serial tests and a parallel tests step
Watch your build
Sit at your build while it runs
Check logs
Find bottlenecks
QA
Thanks!
sso@saucelabs.com
@santiycr