Selenium is a web testing framework that allows for cross-browser testing and integration with continuous integration tools. It has two primary versions, with version 1 using Selenium IDE to record tests as Selenium commands and version 2 using WebDriver APIs to programmatically control browsers. Selenium tests functionality across different browsers for fidelity and can be run across a variety of backend servers and browsers. Setting up Selenium for continuous integration can involve using Selenium Builder for test recording, storing tests on GitHub, running tests via Travis CI on each commit, and using Sauce Labs servers for remote browser control.
5. Selenium IDE
Selenium 1 Test
Selenium Builder
Selenium 1 Code
Selenium 2 Code
Builder JSON
Selenium 1 APIs
Webdriver APIs
Se Interpreter
HTML
Ghost
Selenium Server
IE
Firefox
Chrome
Opera
Android
etc.
6. Selenium 1 vs 2
● v 1 is a list of testing steps
● v 2 is an API for remote-controlling browsers
7. Selenium 1 Tests
● Sequence of test steps
● “Go to this page, click on this link, does this
text appear?”
● Stored as “Selenese” table or code
8.
9. Selenium 2 / Webdriver APIs
● Write code to control the browser
● Python, Java, Ruby, Perl, PHP, C#, node,
Groovy, etc.
10.
11. Locators are for finding stuff
● Locators refer to page elements
● Multiple strategies: id, class, text, xpath…
● Ideally robust to minor page changes
12. Playback fidelity is hard!
● Javascript is everywhere: you can’t test a
page just by looking at the HTML
● Want to run tests quickly but waits needed
● Reliable locators can be hard
● CSS rollovers, element visibility, etc.
13. No silver bullet blah blah blah
●
●
●
●
Selenium uses real browsers for fidelity
Implicit waits sometimes work
Write clean, testable pages
80/20 automated/manual is still nice
14. Getting started with Selenium 2
● Get language bindings
● Write your first test
● Run your first test
16. Builder+GitHub+Travis+Sauce = CI
●
●
●
●
Record tests with Selenium Builder
Store them on GitHub in the project repo
Use Travis to drive test runs on commit
Use Sauce Labs’ Selenium servers
18. Substitutions
● Builder: IDE or hand-coded scripts
● Travis: another CI system, e.g Jenkins
● Sauce OnDemand: your own infrastructure
or another provider like TestingBot