Top Banner
High performance Functional tests based on Selenium Andrii Soldatenko 27-28 February 2015 @a_soldatenko
37
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SeleniumCamp 2015 Andrii Soldatenko

High performance Functional tests

based on Selenium

Andrii Soldatenko 27-28 February 2015

@a_soldatenko

Page 2: SeleniumCamp 2015 Andrii Soldatenko

About me:• Lead QA Automation Engineer at

• Backend Python Developer at

• Speaker at PyCon Ukraine 2014

• Speaker at PyCon Belarus 2015

• @a_soldatenko

Page 3: SeleniumCamp 2015 Andrii Soldatenko

"Tests are the Programmer’s

stone, transmuting fear into boredom."

Page 4: SeleniumCamp 2015 Andrii Soldatenko

We don’t have time for tests

Page 5: SeleniumCamp 2015 Andrii Soldatenko

Test Automation Pyramid

from  http://martinfowler.com/bliki/TestPyramid.html

Page 6: SeleniumCamp 2015 Andrii Soldatenko

Unit tests

Page 7: SeleniumCamp 2015 Andrii Soldatenko

Integration tests

Page 8: SeleniumCamp 2015 Andrii Soldatenko

Functional or UI tests

Page 9: SeleniumCamp 2015 Andrii Soldatenko

How to automate Functional tests for Web?

Page 10: SeleniumCamp 2015 Andrii Soldatenko

Demo

Page 11: SeleniumCamp 2015 Andrii Soldatenko

What is Test Execution Time?

• Faster Tests Mean Faster Development

• Slow Tests Don’t Get Run as Often

Page 12: SeleniumCamp 2015 Andrii Soldatenko

How to calculate test execution time

Page 13: SeleniumCamp 2015 Andrii Soldatenko

How to decrease test execution time?

“Man is a tool-using animal. Without tools he is nothing, with tools he is all.“ - Thomas Carlyle

Page 14: SeleniumCamp 2015 Andrii Soldatenko

xUnit in Pythonparallel

execution pluginsnativetest

coverage

unittest NO NO NO

YES YES YES

YES YES NO

Page 15: SeleniumCamp 2015 Andrii Soldatenko

Parallel test execution

Page 16: SeleniumCamp 2015 Andrii Soldatenko

Demo

Page 17: SeleniumCamp 2015 Andrii Soldatenko

Use Selenium Grid

Node

Node

Node

Hub

Page 18: SeleniumCamp 2015 Andrii Soldatenko

How to setup Selenium Grid locally

Page 19: SeleniumCamp 2015 Andrii Soldatenko

Add Selenium Grid support to tests

Page 20: SeleniumCamp 2015 Andrii Soldatenko

Selenium Grid + Concurrent test execution

Node

Node

Node

HubOR

Page 21: SeleniumCamp 2015 Andrii Soldatenko

Demo

Page 22: SeleniumCamp 2015 Andrii Soldatenko

Selenium Grid in Cloud

Page 23: SeleniumCamp 2015 Andrii Soldatenko

Example

Page 24: SeleniumCamp 2015 Andrii Soldatenko

Use Selenium with PhantomJS

Ghost Driver

https://github.com/ariya/phantomjs/

Page 25: SeleniumCamp 2015 Andrii Soldatenko

What is GhostDriver?

https://github.com/detro/ghostdriver

Page 26: SeleniumCamp 2015 Andrii Soldatenko

PhantomJS: advantages

Page 27: SeleniumCamp 2015 Andrii Soldatenko

PhantomJS: disadvantages

Page 28: SeleniumCamp 2015 Andrii Soldatenko

Demo

Page 29: SeleniumCamp 2015 Andrii Soldatenko

Using http Requests instead of Selenium

Page 30: SeleniumCamp 2015 Andrii Soldatenko

Demo

Page 31: SeleniumCamp 2015 Andrii Soldatenko

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

Page 32: SeleniumCamp 2015 Andrii Soldatenko

“Premature optimization is the root of all evil” - Donald Knuth

Page 33: SeleniumCamp 2015 Andrii Soldatenko

How to find bottlenecks in functional tests?

Page 34: SeleniumCamp 2015 Andrii Soldatenko

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

Page 35: SeleniumCamp 2015 Andrii Soldatenko

Questions

?

Page 36: SeleniumCamp 2015 Andrii Soldatenko

Thank You

[email protected]

@a_soldatenko

http://asoldatenko.com

Page 37: SeleniumCamp 2015 Andrii Soldatenko

We are hiring

[email protected]