SlideShare a Scribd company logo
Selenium
Tips & Tricks
by Dave Haeffner
@TourDeDave
New to Selenium?
• Selenium Bootcamp http://bit.ly/se-bootcamp
• Selenium Guidebook http://bit.ly/se-guidebook
• Weekly Selenium Tips http://bit.ly/se-weekly-tips
http://ElementalSelenium.com
etc.
http://the-internet.herokuapp.com/
Headless
Benefits:
- Speed
- Maintenance
- Screenshotting
Headless w/ Xvfb
http://elementalselenium.com/tips/38-headless
Why use it?
Ideal for running small test suites on a headless machine
e.g., a Continuous Integration (CI) Server
NOTE
- display port collisions
- use unique values
- e.g., CI build number
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Headless w/ GhostDriver
http://elementalselenium.com/tips/46-headless-ghostdriver
http://phantomjs.org/
Why use it?
• Faster execution times
• Also useful for a CI server
• Not limited to just Linux
Step 2 - Start PhantomJS w/ WebDriver flag
Step 1 - Download PhantomJS
http://phantomjs.org/download.html
Step 3 - Connect Your Test to PhantomJS
using Selenium Remote
NOTE
You can also connect PhantomJS to a Selenium Grid
http://bit.ly/ghost-driver-grid
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Visual Testing
A Visual Testing Primer
• check that an application’s UI appears correctly to its users
• goal: find visual bugs before the user does
• e.g., font, layout, rendering issues
• can also be used to verify content
• e.g., charts, dashboards, etc.
• hundreds of assertions for a few lines of code
• at least 16 open source solutions available to choose from
Visual Testing Challenges
• Managing complexity
• False positives
• e.g., shifting content, dynamic content, typos
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Visual Testing Write-ups
http://bit.ly/se-visual-1 Getting Started
http://bit.ly/se-visual-2 False Positives part 1
http://bit.ly/se-visual-3 False Positives part 2
http://bit.ly/se-visual-4 Add Visual Testing To Your Existing Tests
http://bit.ly/se-visual-5 Add Visual Testing To Your BDD Tests
Selenium Grid Resources
• http://elementalselenium.com/tips/26-cloud
• http://elementalselenium.com/tips/52-grid
• http://elementalselenium.com/tips/70-grid-extras
Fun with a Proxy Server
Selenium Browser
Proxy
Server
Application
Under
Test
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
HTTP Status Codes
http://elementalselenium.com/tips/17-retrieve-http-status-codes
Configuration
• Use a proxy server to capture the traffic from your
Selenium test(s)
• Find the status code for the action you’re interested
in (e.g., visiting a URL)
• Assert that the status code is what you expect
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Blacklisting
http://elementalselenium.com/tips/66-blacklist
Configuration
• Use a proxy server to manipulate the traffic from
your Selenium test(s)
• Identify third-party resources that are slow to load
(which could negatively impact your tests)
• Blacklist them (e.g., make it so they don’t load)
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Load Testing
http://elementalselenium.com/tips/68-load-testing-revisited
Configuration
• Use a proxy server to capture the traffic from your
Selenium test(s)
• Convert the HTTP Archive into a JMeter JMX file
• Run the new JMX file with JMeter to enact load on
your application (modify as needed)
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Adapted from ruby-jmeter example from flood.io
https://github.com/flood-io/ruby-jmeter
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Broken Image Checking
http://elementalselenium.com/tips/67-broken-images
Option 1 - Proxy Server
Option 2 - HTTP Library
Option 3 - JavaScript
Option 1: Proxy Server
Proxy Server Cont’d
Proxy Server Cont’d
Proxy Server Cont’d
Option 2: HTTP Library
HTTP Library Cont’d
HTTP Library Cont’d
Option 3: JavaScript
JavaScript Cont’d
JavaScript Cont’d
JavaScript Cont’d
Forgot Password
http://elementalselenium.com/tips/43-forgot-password
Configuration
• Use Selenium to trigger a forgot password workflow
(to a Gmail account) and keep the browser session
active
• Retrieve the e-mail and the password information
via the Gmail API
• Use the password information in the active
Selenium session (if applicable)
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
A/B Testing
http://elementalselenium.com/tips/12-opt-out-of-ab-tests
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
• 3 page states available
• You can identify which state you’re in because
there is different header text for each
• When you’re in the control: A/B Test Control
• For the variation: A/B Test Variation 1
• When you’re not in a test: No A/B Test
http://the-internet.herokuapp.com/abtest
Configuration
• You can easily opt-out of A/B tests by
• forging a cookie
• appending a query to the URL
• This way you get a known state of the page which
isn’t likely to change without your knowledge
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
File Management
Uploading a File
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Workaround
• Rather than use something like AutoIt (which is a
bad idea)
• You can send the file path you want to upload into
the form input field (side-stepping the system
dialog entirely)
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
http://bit.ly/se-file-detector
Downloading a File
http://elementalselenium.com/tips/2-download-a-file
http://elementalselenium.com/tips/8-download-a-file-revisited
http://elementalselenium.com/tips/15-download-secure-files
Two approaches
• Configure Selenium to download to local disk, and
delete the file when done
• Use an HTTP library, perform a HEAD request, and
check the headers for the correct content type &
length.
Why?
• An order of magnitude faster using Selenium
• No need to download the file
With Selenium
With Selenium
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
With an HTTP library
With an HTTP library (for secure files)
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Additional Output
Highlight Elements
http://elementalselenium.com/tips/65-highlight-elements
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Growl Notifications
http://elementalselenium.com/tips/53-growl
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
New to Selenium?
• Selenium Bootcamp http://bit.ly/se-bootcamp
• Selenium Guidebook http://bit.ly/se-guidebook
• Weekly Selenium Tips http://bit.ly/se-weekly-tips
http://ElementalSelenium.com http://bit.ly/oss-es-tips
Get in touch
@TourDeDave
dhaeffner@gmail.com
DaveHaeffner.com

More Related Content

What's hot (20)

PDF
Getting Started with Selenium
Dave Haeffner
 
PDF
How to Use Selenium, Successfully
Sauce Labs
 
PPT
Selenium Primer
Debashish Chakrabarty
 
PPT
Selenium
Adam Goucher
 
PPTX
Selenium with java
Satyam Pandey
 
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Applitools
 
PDF
Automated Web Testing With Selenium
Deepak Mittal
 
PPT
Test automation using selenium
shreyas JC
 
PPT
Selenium
Kalyan ch
 
PPT
Automated Web Testing Using Selenium
Weifeng Zhang
 
PPTX
Introduction to selenium
Archana Krushnan
 
PPT
Selenium
Ruturaj Doshi
 
PDF
Selenium IDE Introduction, Installation and Working
Disha Srivastava
 
PDF
Selenium 2 for PHP(Unit)
AOE
 
PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
PPTX
Selenium - Introduction
Sachin-QA
 
PPT
Selenium Primer
gueste1e4db
 
PPTX
Get Started With Selenium 3 and Selenium 3 Grid
Daniel Herken
 
PPTX
Selenium ppt
Aneesh Rangarajan
 
PPTX
Selenium web driver
Sun Technlogies
 
Getting Started with Selenium
Dave Haeffner
 
How to Use Selenium, Successfully
Sauce Labs
 
Selenium Primer
Debashish Chakrabarty
 
Selenium
Adam Goucher
 
Selenium with java
Satyam Pandey
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Applitools
 
Automated Web Testing With Selenium
Deepak Mittal
 
Test automation using selenium
shreyas JC
 
Selenium
Kalyan ch
 
Automated Web Testing Using Selenium
Weifeng Zhang
 
Introduction to selenium
Archana Krushnan
 
Selenium
Ruturaj Doshi
 
Selenium IDE Introduction, Installation and Working
Disha Srivastava
 
Selenium 2 for PHP(Unit)
AOE
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
Selenium - Introduction
Sachin-QA
 
Selenium Primer
gueste1e4db
 
Get Started With Selenium 3 and Selenium 3 Grid
Daniel Herken
 
Selenium ppt
Aneesh Rangarajan
 
Selenium web driver
Sun Technlogies
 

Similar to Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner (20)

PDF
How to use selenium successfully
TEST Huddle
 
PDF
Mastering Test Automation: How to Use Selenium Successfully
Applitools
 
PDF
How To Use Selenium Successfully (Java Edition)
Dave Haeffner
 
PDF
Selenium Tips & Tricks - StarWest 2015
Andrew Krug
 
PDF
How To Use Selenium Successfully (Java Edition)
Sauce Labs
 
PPTX
Automated Web Testing With Selenium
Jodie Miners
 
DOC
Selenium Automation Using Ruby
Kumari Warsha Goel
 
PPTX
Web testing with Selenium
XBOSoft
 
PPTX
Selenium rc ppt
mindqqa
 
PDF
Selenium Handbook
Suresh Thammishetty
 
PPTX
Automated_Testing_Selenium
Jagdish Kaushal
 
PPTX
Automatedtestingwithselenium shubham jain
Prashant Gurav
 
PPTX
Selenium web driver
Roman Savitskiy
 
PPTX
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
PDF
Selenium Tutorial
prad_123
 
PDF
Selenium Ide Tutorial
metapix
 
PDF
Selenium for-ops
Łukasz Proszek
 
PPT
Selenium Concepts
Swati Bansal
 
PDF
Selenium Automation Testing - A Complete Guide.pdf
kalichargn70th171
 
PPTX
Automation With Selenium
kgrammer
 
How to use selenium successfully
TEST Huddle
 
Mastering Test Automation: How to Use Selenium Successfully
Applitools
 
How To Use Selenium Successfully (Java Edition)
Dave Haeffner
 
Selenium Tips & Tricks - StarWest 2015
Andrew Krug
 
How To Use Selenium Successfully (Java Edition)
Sauce Labs
 
Automated Web Testing With Selenium
Jodie Miners
 
Selenium Automation Using Ruby
Kumari Warsha Goel
 
Web testing with Selenium
XBOSoft
 
Selenium rc ppt
mindqqa
 
Selenium Handbook
Suresh Thammishetty
 
Automated_Testing_Selenium
Jagdish Kaushal
 
Automatedtestingwithselenium shubham jain
Prashant Gurav
 
Selenium web driver
Roman Savitskiy
 
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Selenium Tutorial
prad_123
 
Selenium Ide Tutorial
metapix
 
Selenium for-ops
Łukasz Proszek
 
Selenium Concepts
Swati Bansal
 
Selenium Automation Testing - A Complete Guide.pdf
kalichargn70th171
 
Automation With Selenium
kgrammer
 
Ad

More from Applitools (20)

PDF
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
PDF
Creating Automated Tests with AI - Cory House - Applitools.pdf
Applitools
 
PDF
Navigating EAA Compliance in Testing.pdf
Applitools
 
PDF
AI-Assisted, AI-Augmented & Autonomous Testing
Applitools
 
PDF
Code or No-Code Tests: Why Top Teams Choose Both
Applitools
 
PDF
The ROI of AI-Powered Testing, presented by Applitools
Applitools
 
PDF
Building No-code Autonomous E2E Tests_Applitools.pdf
Applitools
 
PDF
Conquer 6 Testing Challenges_Applitools.pdf
Applitools
 
PDF
Autonomous End-to-End Testing for Online Banking Applications Presented with ...
Applitools
 
PDF
Playwright Visual Testing Best Practices, presented by Applitools
Applitools
 
PDF
Cross-Browser and Cross-Device Testing | Applitools in Action
Applitools
 
PDF
Advanced Debugging Techniques | Applitools in Action.pdf
Applitools
 
PDF
AI-Powered Testing Strategies for the Seasonal Shopping Surge.pdf
Applitools
 
PDF
Test Automation for Dynamic Applications _ Applitools in Action.pdf
Applitools
 
PDF
Proven Approaches to AI-Powered E2E Testing.pdf
Applitools
 
PDF
Applitools Autonomous 2.0 Sneak Peek.pdf
Applitools
 
PDF
Building the Ideal CI-CD Pipeline_ Achieving Visual Perfection
Applitools
 
PDF
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Applitools
 
PDF
Streamlining Your Tech Stack: A Blueprint for Enhanced Efficiency and Coverag...
Applitools
 
PDF
Visual AI for eCommerce: Improving Conversions with a Flawless UI
Applitools
 
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Creating Automated Tests with AI - Cory House - Applitools.pdf
Applitools
 
Navigating EAA Compliance in Testing.pdf
Applitools
 
AI-Assisted, AI-Augmented & Autonomous Testing
Applitools
 
Code or No-Code Tests: Why Top Teams Choose Both
Applitools
 
The ROI of AI-Powered Testing, presented by Applitools
Applitools
 
Building No-code Autonomous E2E Tests_Applitools.pdf
Applitools
 
Conquer 6 Testing Challenges_Applitools.pdf
Applitools
 
Autonomous End-to-End Testing for Online Banking Applications Presented with ...
Applitools
 
Playwright Visual Testing Best Practices, presented by Applitools
Applitools
 
Cross-Browser and Cross-Device Testing | Applitools in Action
Applitools
 
Advanced Debugging Techniques | Applitools in Action.pdf
Applitools
 
AI-Powered Testing Strategies for the Seasonal Shopping Surge.pdf
Applitools
 
Test Automation for Dynamic Applications _ Applitools in Action.pdf
Applitools
 
Proven Approaches to AI-Powered E2E Testing.pdf
Applitools
 
Applitools Autonomous 2.0 Sneak Peek.pdf
Applitools
 
Building the Ideal CI-CD Pipeline_ Achieving Visual Perfection
Applitools
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Applitools
 
Streamlining Your Tech Stack: A Blueprint for Enhanced Efficiency and Coverag...
Applitools
 
Visual AI for eCommerce: Improving Conversions with a Flawless UI
Applitools
 
Ad

Recently uploaded (20)

PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Biography of Daniel Podor.pdf
Daniel Podor
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Designing Production-Ready AI Agents
Kunal Rai
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 

Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner