Selenium Tricks
Selenium Tricks
NOTE
You can also connect PhantomJS to a Selenium Grid
http://bit.ly/ghost-driver-grid
Visual Testing
A Visual Testing Primer
• check that an application’s UI appears correctly to its users
• Managing complexity
• False positives
• http://elementalselenium.com/tips/26-cloud
• http://elementalselenium.com/tips/52-grid
• http://elementalselenium.com/tips/70-grid-extras
Fun with a Proxy Server
Application
Proxy
Selenium Browser Under
Server
Test
HTTP Status Codes
http://elementalselenium.com/tips/17-retrieve-http-status-codes
Configuration
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
• forging a cookie
• You can send the file path you want to upload into
the form input field (side-stepping the system
dialog entirely)
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
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 (for secure files)
Additional Output
Highlight Elements
http://elementalselenium.com/tips/65-highlight-elements
Growl Notifications
http://elementalselenium.com/tips/53-growl
New to Selenium?
DaveHaeffner.com