Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


My experience with Selenium WebDriver at Amazon

Using Selenium for UI test automation frameworks

Amit Garg

on 5 November 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of My experience with Selenium WebDriver at Amazon

My experience with


Introduction to Selenium
Amazon Sponsored Links (text ads)
Challenges in testing these ads
Architecture of the test framework
Challenges for automation
Impact of automation
Non testing applications of Selenium

What is Selenium
Selenium automates browsers. That's it. What you do with that power is entirely up to you.
Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that.

Amit Garg
*Similar ads on combination of page-types, countries, browsers, placements, mobile/tablet apps etc.
Sponsored Links – text ads

<Step stepID='2' description='enter_search_query' type='frontend'>
<Step stepID='3' description='resize_window' type='frontend'>
<Step stepID='4' description='click_next_page' type='frontend'>

caseID='1' description='UI Test'
description='open_gateway_page' type='UI'>


Sample Test
Testcase Data
<Locale locale='uk'>
<search>some value</search>
<Locale locale='jp'>
<search>some value</search>
<Locale locale='
some value
Sample Config
Test Configs
Config Hashmap
some value
frontend_us_browse = ...
frontend_us_detail = ...
frontend_jp_detail = ...
Using Config Hashmap in test case config
Test Runner
Data Provider
Selenium Utils
Direct request simulator
Selenium WebDriver Setup
Amazon Frontend server
Backend Ads service
Backend service logs
Test run logs/reports
Ads properties
Presence of UI elements
Presence of ads, Widget heading, ‘What’s This’ link, Feedback link,
Numbering, Ad Titles, Ad Descriptions, Ad urls
Number of ads
Boolean values for Alignment of UI elements
Vertical alignment of
- Ad titles
- Ad descriptions
- Ad numbering/bullets
- Widget heading with Feedback link
Horizontal alignment of Ad title, description and url for same ad
Spacing between various elements in pixels
Vertical spacing between
- widget heading and first ad
- Two ads
- Last ad and feedback link
Horizontal spacing between
- Numbers/Bullets and Ad title
- Ad title and description
- Ad description and url
Font properties (Style, weight, size, family)
Widget Heading, Whats this link, Ad Title, description, url, Feedback link
UI Verifications for ads
by '
', '
', '
' or '


Sample values for these font properties:


WebElement element1 = driver.findElement(By.id("ABC"));
WebElement element2 = driver.findElement(By.id("XYZ"));

org.openqa.selenium.Point p1, p2;
p1 = element1.getLocation();
p2 = element2.getLocation();

Distance between p1 and p2
vertical = p2.y - p1.y;
horizontal = p2.x - p1.x;

Vertical alignment true if their X-Axis values are same
p2.x - p1.x = 0

Horizontal alignment true if their Y-Axis values are same
p2.y - p1.y = 0
Extracting relative positions between web elements
Extracting font properties for a WebElement
Selenium Hub Setup Steps
Download Selenium standalone jar, IEDriverServer.exe, ChromeDriver.exe

Start the hub (default port 4444)
java -jar selenium-server-standalone-2.26.0.jar -role hub

Setup nodes, register with hub
java -jar selenium-server-standalone-2.26.0.jar -role node -hub http://localhost:4444/grid/register -Dwebdriver.chrome.driver=C:\drivers\chromedriver.exe -Dwebdriver.ie.driver=C:\drivers\IEDriverServer.exe
// Specify host for the Remote Webdriver
URL remoteWebAddress = new URL("http://XX.XX.XX.XXX:4444/wd/hub");

// Initialize a remote webdriver
RemoteWebDriver driver = new RemoteWebDriver(remoteWebAddress,

// Open a page with webdriver

// Do whatever you want to do with the webdriver
How to connect to Webdriver
FirefoxProfile profile = new FirefoxProfile();
DesiredCapabilities dc = DesiredCapabilities.firefox();
//Override user-agent for the profile, change "
mobile user agent
" as needed
profile.setPreference("general.useragent.override", "
Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
//bind the new FF profile with desired capabilities
dc.setCapability(FirefoxDriver.PROFILE, profile);

URL remoteWebAddress = new URL("http://XX.XX.XX.XXX:4444/wd/hub");
//Start remote session with the new settings
RemoteWebDriver driver = new RemoteWebDriver(remoteWebAddress,dc);

// Open a page with webdriver
//do whatever you want with the driver
Architecture of Automation Framework
Fully automated the UI regression testing
More than 30% of QA time saved every week
Increased accuracy of tests. Found issues almost impossible to catch manually
New tests can be added in the xml config files
Support for upcoming expansion of ads on mobile browsers
Selenium WebDriver setup (with multiple browsers behind the hub) usable by multiple teams
Non QA Applications of Selenium
Ads Monitoring tool
Continuously monitor our ads on Amazon retail website in production and report any outages faster than any other monitoring system. This is a simple application but has been extremely useful in catching real-time issues faster than any other system in place.

JavascriptExecutor js = (
) driver;

//Run scripts to
scroll page
to make calendar visible for date selection etc
Executing javascript on page
Emulating Mobile browser on desktop
Use browsers locally or remotely through a hub to test your app
Selenium has relatively less support and online help available for testing on actual device/simulator browsers

Tests are supposed to run automatically with every check-in and the code gets deployed to prod only after the tests pass

On Linux servers without GUI support, we used VNCServer to run a browser

Ajax scenarios like mouseover and scroll generate some events which are used to optimize ads, these had to be generated by running custom javascript on the browser.
Limited Support for Mobile Web Browser Testing
Integration with Amazon continuous deployment pipelines
Running tests on Linux servers without GUI support
Ajax Scenarios
To store the stats collected on the browser
Ad Title
Ad Description
Feedback Link
Widget heading
Ad Numbering
Thank you!!
Snapshot generator
This tool helps to diagnose and explain changes in clicks and CTR by looking at historical versions of the website. It periodically takes screen-shots of a set of urls on Amazon.com website, collects information like placement of ads on the page, number of ads, key UI properties etc and saves them for later review. The tool has been very useful in debugging some of the revenue changes in our ads program which were difficult to explain otherwise.
Non QA Applications of Selenium
Challenges in testing
Multiple widgets on the page
Frequent releases with new features
A lot to test - Custom logic for various conditions
Even smallest of bugs can have huge impact
Constant expansion on new pages/devices etc
Continuous deployments
Full transcript