Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Selenium Framework Design in Data-Driven Testing

You're reading from   Selenium Framework Design in Data-Driven Testing Build data-driven test frameworks using Selenium WebDriver, AppiumDriver, Java, and TestNG

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788473576
Length 354 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Carl Cocchiaro Carl Cocchiaro
Author Profile Icon Carl Cocchiaro
Carl Cocchiaro
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Building a Scalable Selenium Test Driver Class for Web and Mobile Applications FREE CHAPTER 2. Selenium Framework Utility Classes 3. Best Practices for Building Selenium Page Object Classes 4. Defining WebDriver and AppiumDriver Page Object Elements 5. Building a JSON Data Provider 6. Developing Data-Driven Test Classes 7. Encapsulating Data in Data-Driven Testing 8. Designing a Selenium Grid 9. Third-Party Tools and Plugins 10. Working Selenium WebDriver Framework Samples

Third-party grid architecture support including the Sauce Labs Test Cloud

When adding support to the driver class for third-party grids such as Sauce Labs or Perfecto Mobile, users must add conditions in the driver class that set specific preferences, credentials, URLs, and so on, to direct traffic to that test platform. They are really just other Selenium grids to run against in the cloud, which free up the tester from all the maintenance requirements of an in-house grid. The condition to run on one of these third-party platforms can be passed as a parameter to the test, specifically environment. For instance, here is an example of a TestNG XML file using parameters to set up the driver:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="My Test Suite" preserve-order="true" parallel="false" thread-count="1" verbose="2">

<!-- suite parameters -->
<!-- "local", "remote", "saucelabs" -->
<parameter name="environment" value="saucelabs" />

<test name="My Feature Test">
<!-- test parameters -->
<parameter name="browser" value="chrome" />
<parameter name="platform" value="Windows 10" />

or

<parameter name="browser" value="iphone"/>
<parameter name="platform" value="iphone"/>

<classes>
<class name="com.myproject.MyTest" />
</classes>
</test>
</suite>

Each provider will require a different RemoteWebDriver URL, credentials to access their test cloud, preferences, and various other features that would allow access to a DMZ inside a corporate Firewall. Here are some examples of specific Sauce Labs Cloud platform requirements:

  • Tunnel: If the web server, or any other servers, are behind a corporate Firewall and not open to the internet, then a unique tunnel will have to be set up and passed to the driver class as a Desired Capability.
  • Remote URL: Sauce Labs has its own RemoteWebDriver URL for accessing its server at http://SAUCE_USERNAME:[email protected]:80/wd/hub.
  • Preferences: Sauce Labs has a set of unique capabilities that allow the passing of when creating the driver for the test. Examples include screen resolution, browser versions (including latest and beta versions), mobile device types (including physical and simulator/emulator devices), Selenium versions, driver versions, session parameters, results processing, and so on.
The Sauce Labs Wiki documentation, which includes Desired Capabilities and Platform Configurator, is located at https://wiki.saucelabs.com/.
// third party preferences for SauceLabs...

if ( environment.equalsIgnoreCase("saucelabs") ) {
// setup the Selenium Grid capabilities...
String remoteHubURL =
"http://SAUCE_USERNAME:SAUCE_ACCESS_KEY
@ondemand.saucelabs.com:80/wd/hub
";

caps.setCapability("screenResolution",
"1920x1080");
caps.setCapability("recordVideo",
false);
caps.setCapability("tunnelIdentifier",
System.getProperty("TUNNEL_IDENTIFIER"));
...
}
You have been reading a chapter from
Selenium Framework Design in Data-Driven Testing
Published in: Jan 2018
Publisher: Packt
ISBN-13: 9781788473576
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image