Download - Getting Started with Selenium
![Page 1: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/1.jpg)
Getting Started with Selenium
by Dave Haeffner, @TourDeDave
![Page 2: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/2.jpg)
http://www.wpclipart.com/geography/features/chasm.png.html
![Page 3: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/3.jpg)
http://en.wikipedia.org/wiki/Optimal_solutions_for_Rubik's_Cube
![Page 4: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/4.jpg)
Write business valuable tests that are reusable, maintainable and resilient across all relevant browsers.
Then package and scale them for you & your team.
![Page 5: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/5.jpg)
Selenium Overview
• What it is — the Reader’s Digest version
• What it is and is not good at
• IDE vs. Local vs. Remote
• Slow, brittle, and hard to maintain?
![Page 6: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/6.jpg)
Step 1 Define a Test Strategy
![Page 7: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/7.jpg)
Test Strategy1. How does your business make money?
2. What features of your application are being used?
3. What browsers are your users using?
4. What things have broken in the app before?
Outcome: What to test and which browsers to care about
![Page 8: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/8.jpg)
Step 2 Pick a Programming
Language
![Page 9: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/9.jpg)
Programming Language
• Same language as the app?
• Who will own it?
• Build a framework or use an existing one?
• http://bit.ly/seleniumframeworks
![Page 10: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/10.jpg)
2a Java, a brief primer
![Page 11: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/11.jpg)
Java Setup
• Everyone setup?
• Java Software Development Kit (SDK)
• Maven
• Initial test repo from http://bit.ly/se-java-init
![Page 12: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/12.jpg)
Java Concepts• Object Structures (Variables, Methods, & Classes)
• Access Modifiers (public, protected, private)
• Object Types (Strings, Booleans, etc.)
• Actions (Asserts & Conditionals)
• Annotations
• Inheritance
![Page 13: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/13.jpg)
Object Structures
• Variables
• Methods
• Classes
![Page 14: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/14.jpg)
Object Structures Variables
Objects where you can store and retrieve values
![Page 15: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/15.jpg)
Object Structures Methods
Where you can store common actions for reuse
![Page 16: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/16.jpg)
Object Structures Classes
Store the state and behavior of something complex
![Page 17: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/17.jpg)
Access Modifiers
• When specifying an object (e.g., a variable, method, or class) you can apply a modifier
• This modifier denotes what else can access the object (a.k.a. scope)
• private -> protected -> public
• “need-to-know”
![Page 18: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/18.jpg)
Object Types
• Strings ("")
• Booleans (true/false)
![Page 19: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/19.jpg)
Object Types Booleans
![Page 20: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/20.jpg)
Actions
• Assertions
• Conditionals
![Page 21: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/21.jpg)
Actions Assertions
Allows us to test assumptions about our application
![Page 22: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/22.jpg)
Actions Conditionals
A way to break up the flow of codeso only certain chunks of it are executed
based on predefined criteria
![Page 23: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/23.jpg)
AnnotationsA form of metadata
Used by various libraries to enable additional functionality
![Page 24: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/24.jpg)
InheritanceClasses can connect together via a parent/child connection
![Page 25: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/25.jpg)
Additional Java Resources• http://bit.ly/learn-java-1 (Learn Java Online)
• http://bit.ly/learn-java-2 (Oracle Tutorials)
• http://bit.ly/learn-java-3 (tutorialspoint)
• http://bit.ly/learn-java-4 (Free udemy course)
• http://bit.ly/learn-java-5 (Java in a Nutshell book)
• http://bit.ly/learn-java-6 (Java for Testers book)
![Page 26: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/26.jpg)
Step 3 Use Selenium fundamentals
![Page 27: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/27.jpg)
Selenium Fundamentals
• Mimics human action
• Uses a few common actions
• Works with “locators”
Locators tell Selenium which HTML element to interact with
![Page 28: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/28.jpg)
Common Actions
• get();
• findElement();
• click(); //or submit();
• sendKeys();
• isDisplayed();
![Page 29: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/29.jpg)
Locator Strategies• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are: • unique • descriptive • unlikely to change
That rules a few of these out
![Page 30: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/30.jpg)
Locator Strategies• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are: • unique • descriptive • unlikely to change
That rules a few of these out
![Page 31: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/31.jpg)
Locator Strategies• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are: • unique • descriptive • unlikely to change
That rules a few of these out
Start with IDs and Classes
![Page 32: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/32.jpg)
Locator Strategies• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
Good locators are: • unique • descriptive • unlikely to change
That rules a few of these out
Start with IDs and Classes
Use CSS or XPath (with care)
![Page 33: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/33.jpg)
Locator Strategies• Class
• CSS selectors
• ID
• Link Text
• Partial Link Text
• Tag Name
• XPath
CSS vs XPath http://bit.ly/seleniumbenchmarks http://bit.ly/cssxpathexamples
![Page 34: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/34.jpg)
Finding Quality Locators• Inspect the page
• Verify your selection
• e.g., FirePath or FireFinder
• http://bit.ly/verifyinglocators
• Learn through gaming
• http://bit.ly/locatorgame
• Conversation
![Page 35: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/35.jpg)
CSS Selectors
![Page 36: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/36.jpg)
![Page 37: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/37.jpg)
Step 4 Write your first test
![Page 38: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/38.jpg)
Good Test Anatomy
• Write for BDD or xUnit test framework
• Test one thing (atomic)
• Each test can be run independently (autonomous)
• Anyone can understand what it is doing
• Group similar tests together
![Page 40: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/40.jpg)
A Login Example
1. Visit the login form
2. Find the login form’s username field and input text
3. Find the login form’s password field and input text
4. Find the submit button and click it
1. or, find the form and submit it
![Page 41: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/41.jpg)
![Page 42: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/42.jpg)
Your turn: 1. Create a new package called “tests” 2. Create a new file called TestLogin.java 3. Place this code in it 4. Run it to make sure it works
http://bit.ly/se-java-init2
![Page 43: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/43.jpg)
Now to find an assertion
1. Login
2. Inspect the page
3. Find a locator
4. Verify it
5. Add it to the test
HINT: Assert.assertTrue(); driver.findElement().isDisplayed();
Your turn Add an assertion to your test
![Page 44: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/44.jpg)
![Page 45: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/45.jpg)
![Page 46: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/46.jpg)
Exception Handling• org.openqa.selenium.NoSuchElementException:
Unable to locate element: {"method":"css selector","selector":".flash.error"}
• Most common ones you’ll run into: NoSuchElement and StaleElementReferenceError
• A list of all WebDriver exceptions: http://bit.ly/se-exceptions-java
![Page 48: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/48.jpg)
Step 5 Write reusable and
maintainable test code
![Page 49: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/49.jpg)
Page Objects
![Page 50: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/50.jpg)
Application Under Test
Test 1 Test 2 Test 3 Test 4 Test 5Test 1 Test 2 Test 3 Test 4 Test 5
Need to update EVERY test :-(
![Page 51: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/51.jpg)
Application Under TestPage Object(s)
Test 1 Test 2 Test 3 Test 4 Test 5
Need to update JUST the page object :-D
![Page 52: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/52.jpg)
Let’s look at a page object for login
![Page 53: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/53.jpg)
Your Turn 1. create a new package called “pageobjects” 2. create a new file in it called Login.java 3. add this code to it 4. update your TestLogin file to use it 5. run your test to make sure it still works
http://bit.ly/se-java-init2
![Page 54: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/54.jpg)
And here’s what the test looks like when using it
![Page 55: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/55.jpg)
Page object helpers: http://bit.ly/po-html-elements http://bit.ly/po-page-factory
![Page 56: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/56.jpg)
Base Page Objecta.k.a. Selenium Wrapper
or Base Utility Class
![Page 57: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/57.jpg)
Selenium Commands
Page Object 1
Page Object 2
Page Object 3
Page Object 4
Page Object 5
![Page 58: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/58.jpg)
Base Page Object
Page Object 1
Page Object 2
Page Object 3
Page Object 4
Page Object 5
Selenium Commands
• Global reuse • More readable • Insulates you from
Selenium API changes http://bit.ly/se-upgrade
![Page 59: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/59.jpg)
Let’s take a look at a Base Page Object
![Page 60: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/60.jpg)
Your Turn 1. create a new file in “pageobjects”, Base.java 2. add this code to it 3. update your page object to use it 4. run your tests to make sure they still work
http://bit.ly/se-java-init2
![Page 61: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/61.jpg)
And here it is implemented
![Page 62: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/62.jpg)
![Page 63: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/63.jpg)
How everything fits together
Test TestTest
Page Object
Page Object
Base Page
Object
Tests use page objects
Page objects inherit the base page object
The base page object wraps your Selenium commands
![Page 64: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/64.jpg)
Step 6 Make your tests resilient
![Page 65: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/65.jpg)
Waiting
![Page 66: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/66.jpg)
Thread.sleep(); Implicit wait Explicit waits
![Page 67: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/67.jpg)
Thread.sleep(); Implicit wait Explicit waits
![Page 69: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/69.jpg)
Explicit Waits
• Specify an amount of time, and an action
• Selenium will try repeatedly until either:
• The action is completed, or
• The amount of time specified has been reached (and throw a timeout exception)
![Page 70: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/70.jpg)
![Page 71: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/71.jpg)
Your Turn 1. implement this code in pageobjects/Base.java 2. create a new page object to for dynamic_loading/1
• pageobjects/DynamicLoading.java • http://the-internet.herokuapp.com/dynamic_loading/1
3. create a test to use the page object • e.g., tests/TestDynamicLoading.java
http://bit.ly/se-java-init2
![Page 72: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/72.jpg)
pageobjects/DynamicLoading.java
![Page 73: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/73.jpg)
Browser Timing Considerations
![Page 74: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/74.jpg)
Recap1. Test Strategy
2. Programming Primer
3. Writing Your First Test
4. Page Objects
5. Base Page Object
6. Waiting
Code from morning session: http://bit.ly/se-java-init2
Code going forward: http://bit.ly/se-java-init-3
![Page 75: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/75.jpg)
Step 7 Prep for use
![Page 76: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/76.jpg)
Test Harness
• Central setup and teardown
• Configurable at run-time (with sensible defaults)
• Reporting & Logging
• Parallelization
• Test Grouping
![Page 77: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/77.jpg)
Central setup/teardown
More on JUnit Rules: http://bit.ly/junit-rules
Your turn 1. Create a “Base.java” file in “tests” 2. Add this code to it
![Page 78: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/78.jpg)
Updated testYour turn 1. Update your tests to establish inheritance 2. Remove un-necessary setup & teardown 3. Run your tests to make sure they work
![Page 79: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/79.jpg)
Simple config with defaults
Your turn1. Create a new file in “tests”called Config.java2. Implement it into pageobjects/Base.java
![Page 80: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/80.jpg)
Reporting & Logging
• Machine readablee.g., JUnit XML
• Human readable e.g., screenshots, failure message, stack trace
Fantastic Test Report Tool http://bit.ly/se-reporter (Allure Framework)
![Page 81: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/81.jpg)
Parallelization• In code
• Through your test runner
• Through your Continuous Integration (CI) server
#protip Enforce random order execution of tests http://bit.ly/junit-random-order
Recommended approach: http://bit.ly/mvn-surefire
![Page 82: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/82.jpg)
Your turn 1. Open pom.xml 2. Add this to the bottom of it 3. Save the file
Run them 1. Open the command prompt 2. Navigate to the project dir 3. Run them with mvn clean test
![Page 83: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/83.jpg)
Test Grouping• Metadata (a.k.a. Categories)
• Enables “test packs”
• Some category ideas
• defect
• shallow & deep
• story number
More info: bit.ly/junit-categories
![Page 84: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/84.jpg)
Your turn 1. In “tests” create a new package called “groups” 2. Create an interface in “groups” (e.g., Shallow.java) 3. Annotate a test (or tests) to use this Category
![Page 85: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/85.jpg)
Your turn 1. Open pom.xml 2. Add properties group 3. Add groups configuration 4. Save the file
![Page 86: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/86.jpg)
Running Categories
Your turn - Run your tests from the command-line
![Page 87: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/87.jpg)
Step 8 Add in cross-browser
execution
![Page 88: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/88.jpg)
Locallyhttp://bit.ly/se-chromedriver http://bit.ly/se-firefoxdriver http://bit.ly/se-iedriver http://bit.ly/se-operadriver (12.16) http://bit.ly/se-safaridriver (!Windows)
![Page 89: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/89.jpg)
Locally with Chrome
Your turn 1. Create a “vendor” directory 2. Download ChromeDriver into it 3. Add this code to tests/Base.java
http://bit.ly/download-chromedriver
![Page 90: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/90.jpg)
Grid
Grid Hub
Browser
Tests
All done with the Selenium Standalone Server Just requires additional runtime flags
Grid Node
Grid Node
Grid Node
Browser
Browser
![Page 91: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/91.jpg)
GridHub
Node(s)
Your turn • Download the Selenium jar • Stand up a grid with a nodehttp://bit.ly/download-selenium
![Page 92: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/92.jpg)
GridYour turn • Update tests/Base.java • Run your tests on the gridmvn clean test -Dhost=grid
![Page 93: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/93.jpg)
More on Selenium Grid
• http://bit.ly/se-grid-docs • http://bit.ly/se-grid-post • http://bit.ly/se-grid-extras • http://bit.ly/se-grid-scaler
![Page 94: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/94.jpg)
Sauce Labs
Sauce Labs BrowserTests
![Page 95: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/95.jpg)
Sauce Labs cont’dYour turn
1. Create a free trial account • https://saucelabs.com/signup
2. Add this code to tests/Base.java
![Page 96: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/96.jpg)
Sauce LabsAdditional Considerations - Test name - Pass/Fail status - Secure tunnel
More on Sauce: https://saucelabs.com/platforms http://bit.ly/sauce-post http://bit.ly/sauce-tutorial-java
![Page 97: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/97.jpg)
![Page 98: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/98.jpg)
Your turn 1. Add this to tests/Base.java 2. Re-run your tests in Sauce 3. Confirm that the test name is passed
![Page 99: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/99.jpg)
![Page 100: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/100.jpg)
![Page 101: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/101.jpg)
![Page 102: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/102.jpg)
Step 9 Build an automated
feedback loop
![Page 103: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/103.jpg)
Feedback loops• The goal: Find failures early and often
• Done with continuous integration and notifications
• Notifications e.g., remote: Email, chat, SMSin-person: audio/visual, public shaming
![Page 104: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/104.jpg)
Code Committed
Unit/Integ. (pass?)
Deploy to autom. test
server (success?)
Run automated
tests (pass?)
Deploy to next env.
yes
yes
yes
Notify team if no
Code Promotion
Bonus points: stop the line
![Page 105: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/105.jpg)
Simple CI configuration1. Create a Job
2. Pull In Your Test Code
3. Set up Build Triggers
4. Configure Build steps
5. Configure Test Reports
6. Set up Notifications
7. Run Tests & View The Results
8. High-five your neighbor
![Page 106: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/106.jpg)
![Page 107: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/107.jpg)
Simple CI configuration1. Download “Latest and greatest” from
http://jenkins-ci.org/
2. Launch it from the command-line with `java-jar jenkins.war`
3. Visit http://localhost:8080 in your browser
4. Create a job to run your Selenium tests on a specific browser (e.g., IE8)
5. Manually run the job
6. High-five your neighbor
Your turn
![Page 108: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/108.jpg)
![Page 109: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/109.jpg)
Step 10 Find information on
your own
http://bit.ly/se-info-slides
http://bit.ly/se-info-video
![Page 110: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/110.jpg)
Elemental Selenium (3)
Selenium HQ (1) Documentation & Tips
Issue Tracker Guidance (23) Straight To The Source (24) IRC Chat Channel (25)
Selenium Testing Tools Cookbook (18) The Selenium Guidebook (19)
Selenium Design Patterns (21)
All in-person Selenium Meetups (13) How to start your own (14)
Selenium Developer Google Group (10) Agile Testing Yahoo Group (11)
Selenium Wiki (2)
Books
Meetups
Mailing Lists
Forums
The good stuff
http://bit.ly/se-info-#
Videos
Selenium LinkedIn Users Group (6) Stack Overflow (7) Quora (8)
Selenium Users Google Group (9)
The Selenium Hangout (12)
Conference talks (15) Meetup talks (16)
Selenium 2 Testing Tools (17)
Selenium Simplified (20)
Issue Tracker (22)
BlogsThe official Selenium blog (4) “All” Selenium blogs (5)
![Page 111: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/111.jpg)
Steps to solve the puzzle1. Define a Test Strategy
2. Pick a programming language
3. Use Selenium Fundamentals
4. Write Your First Test
5. Write re-usable and maintainable test code
6. Make your tests resilient
7. Package your tests into a framework
8. Add in cross-browser execution
9. Build an automated feedback loop
10. Find information on your own
Finished code at http://bit.ly/se-java-init-3
![Page 112: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/112.jpg)
Write business valuable tests that are reusable, maintainable and resilient across all relevant browsers.
Then package them and scale them for you & your team.
![Page 113: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/113.jpg)
–Dave Haeffner
“You may think your puzzle is unique. But really, everyone is
trying to solve the same puzzle. Yours is just configured
differently — and it’s solvable”
![Page 115: Getting Started with Selenium](https://reader031.vdocuments.us/reader031/viewer/2022030309/58f280d21a28ab697d8b458f/html5/thumbnails/115.jpg)
Get in touch
@TourDeDave
DaveHaeffner.com