Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

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.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

My experience with Selenium WebDriver at Amazon

Using Selenium for UI test automation frameworks
by

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
Selenium

at


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
Q&A

Agenda
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.

http://www.seleniumhq.org
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'>
<Input>
<GUIAction>enter_search_query</GUIAction>
<Query>flowers</Query>
</Input>
<Validation>
<GUIValidation>load{search_page_validation}</GUIValidation>
</Validation>
</Step>
<Step stepID='3' description='resize_window' type='frontend'>
<Input>
<GUIAction>resize_window</GUIAction>
<ResizeX>800,800</ResizeX>
</Input>
</Step>
<Step stepID='4' description='click_next_page' type='frontend'>
<Input>
<GUIAction>click_next_page</GUIAction>
</Input>
<Validation>
<GUIValidation>load{search_page_validation}</GUIValidation>
</Validation>
</Step>
</Case>

<
Case
caseID='1' description='UI Test'
groups='gui,all'
country='us'>
<Step
stepID='1'
description='open_gateway_page' type='UI'>
<
Input
>

<GUIAction>open_page</GUIAction>
<URL>http://www.amazon.com</URL>
</Input>
<
Validation
>

<GUIValidation>
load{frontend_us_search}
</GUIValidation>
</Validation>
</Step>
Sample Test
Testcase Data
<Locale locale='uk'>
<search>some value</search>
<browse>....</browse>
<detail>.....</detail>
</Locale>
<Locale locale='jp'>
<search>some value</search>
<browse>....</browse>
<detail>.....</detail>
</Locale>
</frontend>
</Config>
<Config>
<
frontend
>
<Locale locale='
us
'>
<
search
>
some value
</search>
<browse>....</browse>
<detail>.....</detail>
</Locale>
Sample Config
Test Configs
Config Hashmap
frontend_us_search
=
some value
frontend_us_browse = ...
frontend_us_detail = ...
-
-
frontend_jp_detail = ...
Load{
frontend_us_search
}
Using Config Hashmap in test case config
Test Runner
(TestNG)
Data Provider
Selenium Utils
Direct request simulator
Selenium WebDriver Setup
Amazon Frontend server
Backend Ads service
Backend service logs
Test run logs/reports
Verifications
Ads properties
1.
Presence of UI elements
Presence of ads, Widget heading, ‘What’s This’ link, Feedback link,
Numbering, Ad Titles, Ad Descriptions, Ad urls
2.
Number of ads
3.
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
4.
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
5.
Font properties (Style, weight, size, family)
Widget Heading, Whats this link, Ad Title, description, url, Feedback link
UI Verifications for ads
//replace
<<Font_Property>>
by '
font-style
', '
font-size
', '
font-weight
' or '
font-family
'

webdriver.findElement(By.xpath("//span[@class='XYZ']")).getCssValue("
<<Font_Property>>
")


Sample values for these font properties:

font-style
=normal,
font-size
=12.0333px,
font-family
=Verdana,Arial,Helvetica,sans-serif,
font-weight
=700

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
http://code.google.com/p/selenium/downloads/list


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,
DesiredCapabilities.firefox());

// Open a page with webdriver
driver.get("http://www.amazon.com");

// 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
driver.get("http://www.amazon.com");
//do whatever you want with the driver
Challenges/Learnings
Architecture of Automation Framework
Impact
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 = (
JavascriptExecutor
) driver;
js.executeScript("
<<YOUR SCRIPT>>
");

//Run scripts to
scroll page
,
mouseover
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
Ad URL
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
http://lnkd.in/kw99Ym
amitkgarg@gmail.com
facebook.com/tinkugarg
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