SlideShare a Scribd company logo
Selenium
Tips & Tricks
by Dave Haeffner
New to Selenium?
• Selenium Bootcamp http://se.tips/se-bootcamp
• Selenium Guidebook http://se.tips/se-guidebook
• Weekly Selenium Tips http://se.tips/se-weekly-tips
http://ElementalSelenium.com
http://the-internet.herokuapp.com/
Headless
Benefits:
- Speed
- Maintenance
- Screenshotting
http://se.tips/all-headless-browsers
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
NOTE
- display port collisions
- use unique values
- e.g., CI build number
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://se.tips/ghost-driver-grid
Option 1
Practical Tips & Tricks for Selenium Test Automation
Step 2 - Tell Selenium where it is
Step 1 - Download PhantomJS
http://phantomjs.org/download.html
Step 3 - Launch Selenium with PhantomJS locally
Option 2
Practical Tips & Tricks for Selenium Test Automation
Visual Testing
A Visual Testing Primer
• Check that an application’s UI appears correctly
• Can also be used to verify content
• Hundreds of assertions for a few lines of code
Visual Testing Challenges
• Managing complexity
• False positives
• e.g., shifting content, dynamic content, typos
Practical Tips & Tricks for Selenium Test Automation
In pom.xml
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Visual Testing Write-ups
http://se.tips/se-visual-1 Getting Started
http://se.tips/se-visual-2 False Positives part 1
http://se.tips/se-visual-3 False Positives part 2
http://se.tips/se-visual-4 Add Visual Testing To Your Existing Tests
http://se.tips/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
http://bmp.lightbody.net/
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
Practical Tips & Tricks for Selenium Test Automation
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
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
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
https://flood.io/har2jmx
http://se.tips/selenium-to-jmeter
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
Option 1: Proxy Server
Option 1: Proxy Server
Option 2: HTTP Library
Option 2: HTTP Library
Option 2: HTTP Library
Option 3: JavaScript
Option 3: JavaScript
Option 3: JavaScript
Forgot Password
http://elementalselenium.com/tips/43-forgot-password
Configuration
• Use Selenium to trigger a forgot password workflow
(to an send to a real email address) and keep the
browser session active
• Retrieve the e-mail and the password information
via the email provider’s API
• Use the password information in the active
Selenium session (if applicable)
NOTE
- not free
- open issue
A/B Testing
http://elementalselenium.com/tips/12-opt-out-of-ab-tests
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
• 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
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
File Management
Uploading a File
http://elementalselenium.com/tips/1-upload-a-file
Practical Tips & Tricks for Selenium Test Automation
Options
• GUI manipulation with something like AutoIt
• Input the file path into the form field (side-stepping
the system dialog)
http://se.tips/grid-file-upload
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
With an HTTP library
With an HTTP library
Additional Output
Highlight Elements
http://elementalselenium.com/tips/65-highlight-elements
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
Growl Notifications
http://elementalselenium.com/tips/53-growl
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
More Selenium Resources
• Selenium Bootcamp http://se.tips/se-bootcamp
• Weekly Selenium Tips http://se.tips/se-weekly-tips
• Weekly Se Tip Code http://se.tips/oss-tip-code
• Selenium Guidebook http://se.tips/se-guidebook
Available in Java and Ruby
(C#, Python, & JS coming soon!)
https://seleniumguidebook.com

More Related Content

PDF
Selenium Tips & Tricks
PDF
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
PDF
Selenium Best Practices with Jason Huggins
PDF
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
PDF
Selenium 2 - PyCon 2011
PPT
Selenium
PDF
How to Use Selenium, Successfully
PDF
How To Use Selenium Successfully
Selenium Tips & Tricks
Practical Tips & Tricks for Selenium Test Automation - Dave Haeffner
Selenium Best Practices with Jason Huggins
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium 2 - PyCon 2011
Selenium
How to Use Selenium, Successfully
How To Use Selenium Successfully

What's hot (20)

PPTX
Selenium WebDriver - Test automation for web applications
PDF
How To Use Selenium Successfully (Java Edition)
PPTX
Selenium for Jobseekers
PPT
Selenium
ODP
Mastering selenium for automated acceptance tests
PPTX
Moving From a Selenium Grid to the Cloud - A Real Life Story
PDF
Basics of Selenium IDE,Core, Remote Control
PDF
Automated Web Testing With Selenium
PDF
Testing Code.org's Interactive CS Curriculum
PPT
Selenium Primer
PPT
Selenium
PPTX
Automation - web testing with selenium
PDF
How To Use Selenium Successfully
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
PPTX
Selenium
PDF
Introduction to Protractor
PPTX
Automated Testing using JavaScript
PPTX
Selenium web driver
PDF
Getting Started with Selenium
PDF
Selenium web driver
Selenium WebDriver - Test automation for web applications
How To Use Selenium Successfully (Java Edition)
Selenium for Jobseekers
Selenium
Mastering selenium for automated acceptance tests
Moving From a Selenium Grid to the Cloud - A Real Life Story
Basics of Selenium IDE,Core, Remote Control
Automated Web Testing With Selenium
Testing Code.org's Interactive CS Curriculum
Selenium Primer
Selenium
Automation - web testing with selenium
How To Use Selenium Successfully
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Selenium
Introduction to Protractor
Automated Testing using JavaScript
Selenium web driver
Getting Started with Selenium
Selenium web driver
Ad

Viewers also liked (20)

PPT
Test Automation In The Hands of "The Business"
PPTX
DevOps Pipelines and Metrics Driven Feedback Loops
PPTX
How to pass a coding interview as an automation developer talk - Oct 17 2016
PDF
Transitioning from Traditional to Modern QA
PDF
Design Patterns for Scalable Test Automation With Selenium & WebdriverIO
PDF
Automation Best Practices
PDF
Selenium, Appium, and Robots!
PPT
BDD with JBehave and Selenium
PDF
Managers, Future Proof Your Automation
PDF
Appium: Prime Cuts
PPTX
Structured Functional Automated Web Service Testing
PDF
Easy Continuous Deployment You Can Trust (Webinar)
PPTX
Introduction to OWASP
PPT
Selenium Primer
PPT
QSpiders - Automation using Selenium
PDF
Software Entomology or Where Do Bugs Come From?
DOCX
Automated software testing
PDF
Cleaning Up the Dirt of the Nineties - How New Protocols are Modernizing the Web
PPTX
QSpiders - Selenium Webdriver
PDF
Fast and Good: Alternate Approaches to Quality at Etsy - STPCon fall 2011
Test Automation In The Hands of "The Business"
DevOps Pipelines and Metrics Driven Feedback Loops
How to pass a coding interview as an automation developer talk - Oct 17 2016
Transitioning from Traditional to Modern QA
Design Patterns for Scalable Test Automation With Selenium & WebdriverIO
Automation Best Practices
Selenium, Appium, and Robots!
BDD with JBehave and Selenium
Managers, Future Proof Your Automation
Appium: Prime Cuts
Structured Functional Automated Web Service Testing
Easy Continuous Deployment You Can Trust (Webinar)
Introduction to OWASP
Selenium Primer
QSpiders - Automation using Selenium
Software Entomology or Where Do Bugs Come From?
Automated software testing
Cleaning Up the Dirt of the Nineties - How New Protocols are Modernizing the Web
QSpiders - Selenium Webdriver
Fast and Good: Alternate Approaches to Quality at Etsy - STPCon fall 2011
Ad

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

PDF
How to use selenium successfully
PDF
Mastering Test Automation: How to Use Selenium Successfully
PPT
Selenium (2)
PPT
Selenium (2)
PDF
How To Use Selenium Successfully (Java Edition)
PDF
How to Un-Flake Flaky Tests - A New Hire's Toolkit
PDF
Deep Dive Into NightWatch- Workshop by Pallavi Sharma.pdf
PDF
How to Un-Flake Flaky Tests - A New Hire's Toolkit
PPTX
Automated Web Testing With Selenium
PPT
Selenium (1)
PDF
Selenium 2 for PHP(Unit)
 
PPTX
Best java automation training institute in Bangalore - Selenium Labs
PPT
Selenium Introduction
PPTX
Increase selenium tests stability via java script
PPT
Selenium classes in mumbai
PPTX
Selenium Introduction and IDE
PPT
Selenium testing - Handle Elements in WebDriver
PDF
Selenium Handbook
PPTX
Automated Acceptance Testing from Scratch
PPTX
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
How to use selenium successfully
Mastering Test Automation: How to Use Selenium Successfully
Selenium (2)
Selenium (2)
How To Use Selenium Successfully (Java Edition)
How to Un-Flake Flaky Tests - A New Hire's Toolkit
Deep Dive Into NightWatch- Workshop by Pallavi Sharma.pdf
How to Un-Flake Flaky Tests - A New Hire's Toolkit
Automated Web Testing With Selenium
Selenium (1)
Selenium 2 for PHP(Unit)
 
Best java automation training institute in Bangalore - Selenium Labs
Selenium Introduction
Increase selenium tests stability via java script
Selenium classes in mumbai
Selenium Introduction and IDE
Selenium testing - Handle Elements in WebDriver
Selenium Handbook
Automated Acceptance Testing from Scratch
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...

More from Sauce Labs (20)

PDF
Simplify Salesforce Testing with AI-Driven Codeless Tools
PDF
Testing on Mobile Devices with Location Services
PDF
Your Framework for Success: introduction to JavaScript Testing at Scale
PDF
Automating Hybrid Applications with Appium
PDF
Quality at Speed: More API Testing, Less UI Testing
PPTX
Creating Digital Confidence with Test Automation
PDF
Just Enough (Automated) Testing
PDF
Using Axe to Add Accessibility Checks to Your Existing Selenium Tests
PDF
How Open Source Helps to Bring Back Product Obsession
PDF
Webinar: A Sneak Peek at Selenium 4 with Simon Stewart
PDF
[Deu] Test Automatisierung Mit Web Driver.io
PDF
Accelerating Innovation: Leveraging Open Source to Optimize Your Shift-Left I...
PDF
Accelerating Your Digital Agenda with Continuous Testing ft. Forrester
PDF
How to Measure Success in Continuous Testing
PDF
From Zero to 2.7 Million - How Verizon Media Embraced Open Source to Accelera...
PDF
5 Steps to Jump Start Your Test Automation
PDF
Sauce Labs Webinar: Rising Importance of Software Testing
PDF
BDD With Selenide by Hima Bindu Peteti
PDF
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
PDF
Continuous Delivery for "Mature" Codebases by Melisa Benua
Simplify Salesforce Testing with AI-Driven Codeless Tools
Testing on Mobile Devices with Location Services
Your Framework for Success: introduction to JavaScript Testing at Scale
Automating Hybrid Applications with Appium
Quality at Speed: More API Testing, Less UI Testing
Creating Digital Confidence with Test Automation
Just Enough (Automated) Testing
Using Axe to Add Accessibility Checks to Your Existing Selenium Tests
How Open Source Helps to Bring Back Product Obsession
Webinar: A Sneak Peek at Selenium 4 with Simon Stewart
[Deu] Test Automatisierung Mit Web Driver.io
Accelerating Innovation: Leveraging Open Source to Optimize Your Shift-Left I...
Accelerating Your Digital Agenda with Continuous Testing ft. Forrester
How to Measure Success in Continuous Testing
From Zero to 2.7 Million - How Verizon Media Embraced Open Source to Accelera...
5 Steps to Jump Start Your Test Automation
Sauce Labs Webinar: Rising Importance of Software Testing
BDD With Selenide by Hima Bindu Peteti
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Continuous Delivery for "Mature" Codebases by Melisa Benua

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Modernizing your data center with Dell and AMD
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
A Presentation on Artificial Intelligence
PDF
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation_ Review paper, used for researhc scholars
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Modernizing your data center with Dell and AMD
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
A Presentation on Artificial Intelligence
cuic standard and advanced reporting.pdf

Practical Tips & Tricks for Selenium Test Automation