High performance
Functional tests
based on Selenium
Andrii Soldatenko
27-28 February 2015
@a_soldatenko
About me:
• Lead QA Automation Engineer at
• Backend Python Developer at
• Speaker at PyCon Ukraine 2014
• Speaker at PyCon Belarus 2015
• @a_soldatenko
"Tests are
the Programmer’s
stone,
transmuting fear
into boredom."
We don’t have time
for tests
Test Automation Pyramid
from	
  http://martinfowler.com/bliki/TestPyramid.html
Unit tests
Integration tests
Functional or UI tests
How to automate
Functional tests for Web?
Demo
What is
Test Execution Time?
• Faster Tests Mean Faster Development
• Slow Tests Don’t Get Run as Often
How to calculate test
execution time
How to decrease test
execution time?
“Man is a tool-using animal.
Without tools he is nothing, with
tools he is all.“ - Thomas Carlyle
xUnit in Python
parallel
execution
plugins
native
test
coverage
unittest NO NO NO
YES YES YES
YES YES NO
Parallel
test execution
Demo
Use Selenium Grid
Node
Node
Node
Hub
How to setup
Selenium Grid locally
Add Selenium Grid
support to tests
Selenium Grid +
Concurrent test execution
Node
Node
Node
Hub
OR
Demo
Selenium Grid in Cloud
Example
Use Selenium with
PhantomJS
Ghost
Driver
https://github.com/ariya/phantomjs/
What is GhostDriver?
https://github.com/detro/ghostdriver
PhantomJS:
advantages
PhantomJS:
disadvantages
Demo
Using http Requests
instead of Selenium
Demo
Approach
Execution
Time
%
num
processes
Selenium WebDriver 22.76 sec 100% 1
Selenium + py.test 9.24 sec 40% 4
Selenium + PhantomJS 15.55 sec 68% 1
Selenium + PhantomJS 9.98 sec 43% 4
Selenium + PhantomJS +
Requests
10.9 sec 47% 1
Selenium + PhantomJS +
Requests
6.1 sec 26% 4
“Premature optimization is the
root of all evil” - Donald Knuth
How to find bottlenecks
in functional tests?
Final Thoughts
• Don’t test constants
• Avoid double-testing functionality
• Try to test behavior rather than implementation
• Use Continuous Integration
• Slow tests kill productivity
• Use explicit rather than implicit waits and wait pattern
Questions
?
Thank You
a_soldatenko@wargaming.net
@a_soldatenko
http://asoldatenko.com
We are hiring
a_soldatenko@wargaming.net

SeleniumCamp 2015 Andrii Soldatenko