org.kuali.rice.testtools.selenium
Class SauceLabsWebDriverHelper

java.lang.Object
  extended by org.kuali.rice.testtools.selenium.SauceLabsWebDriverHelper
All Implemented Interfaces:
com.saucelabs.common.SauceOnDemandSessionIdProvider

public class SauceLabsWebDriverHelper
extends Object
implements com.saucelabs.common.SauceOnDemandSessionIdProvider

Helper class for RemoteWebDriver when writing Selenium tests making use of Saucelabs or Sauce OnDemand.

Saucelabs properties need to be set as JVM arguments. See the SAUCE_ Constants defined below. Required saucelabs parameters are: REMOTE_DRIVER_SAUCELABS_PROPERTY (master use saucelabs flag), SAUCE_USER_PROPERTY, SAUCE_KEY_PROPERTY, SAUCE_VERSION_PROPERTY.

An example:

-Dremote.public.url=env14.rice.kuali.org -Dremote.driver.saucelabs -Dsaucelabs.user=YOUR-SAUCELABS-USER
 -Dsaucelabs.key=YOUR-SAUCELABS-KEY -Dsaucelabs.browser.version=22 -Dsaucelabs.platform=linux -Dsaucelabs.browser=ff
 -Dremote.public.user=admin -Drice.version=42222
 

To make use of SauceLabsWebDriverHelper, call its setUp(java.lang.String, java.lang.String) with the Test Class and Test Name and retrieve the configured WebDriver using getDriver() You'll also need to call getSessionId() which you'll pass into the tearDown(boolean, java.lang.String, java.lang.String, java.lang.String) (along with the tests passed state).

In your test setUp:

 SauceLabsWebDriverHelper saucelabs = new SauceLabsWebDriverHelper();
 saucelabs.setUp(className, testName);
 driver = saucelabs.getDriver();
 
 

In your test tearDown:

 SauceLabsWebDriverHelper.tearDown(passed, sessionId);
 
 

Also includes the Sauce JUnit helper classes, which will use the Sauce REST API to mark the Sauce Job as passed/failed.

In order to use SauceOnDemandTestWatcher the SauceOnDemandSessionIdProvider interface is implemented.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
 com.saucelabs.common.SauceOnDemandAuthentication authentication
           Constructs a SauceOnDemandAuthentication instance using the supplied user name/access key.
static String REMOTE_DRIVER_SAUCELABS_PROPERTY
           Use Saucelabs flag, required.
static String SAUCE_BROWSER_PROPERTY
           Saucelabs browser, default is Firefox.
static String SAUCE_BUILD_PROPERTY
           Suacelabs build displayed as saucelabs build, default is unknown.
static String SAUCE_DOWNLOAD_SCRIPT_PROPERTY
           Create a unix shell script to download saucelab resources, default is false.
static String SAUCE_IDLE_TIMEOUT_SECONDS_PROPERTY
           Saucelabs idle timeout in seconds, default is 180.
static String SAUCE_IE_INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS_PROPERTY
           Saucelabs ignore security domains in IE, which can introduce flakiness, default is true.
static String SAUCE_KEY_PROPERTY
           Saucelabs key, required.
static String SAUCE_MAX_DURATION_SECONDS_PROPERTY
           Saucelabs max duration in seconds, default is 480.
static String SAUCE_PLATFORM_PROPERTY
           Saucelabs platform (OS) replace spaces with underscores, default is Linux.
static String SAUCE_POPUP_PROPERTY
           Saucelabs popup disable setting, default is false (not disabled).
static String SAUCE_REST_API_DELAY_MS
           Saucelabs REST API delay in milliseconds, default is 5000.
static String SAUCE_SHARE_PROPERTY
           Saucelabs share setting, default is public restricted.
static String SAUCE_USER_PROPERTY
           Saucelabs user, required.
static String SAUCE_VERSION_PROPERTY
           Saucelabs browser Version, required.
 
Constructor Summary
SauceLabsWebDriverHelper()
           
 
Method Summary
 org.openqa.selenium.WebDriver getDriver()
           Returns the (RemoteWebDriver) driver.
 String getSessionId()
           
 void setUp(String className, String testName)
           Saucelabs setUp.
 void tearDown(boolean passed, String sessionId, String className, String testName)
           Saucelabs tearDown, flag the tests as passed or failed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REMOTE_DRIVER_SAUCELABS_PROPERTY

public static final String REMOTE_DRIVER_SAUCELABS_PROPERTY

Use Saucelabs flag, required.

For ease of disabling saucelabs without having to remove other saucelabs property settings, if not present saucelabs will not be used.

-Dremote.driver.saucelabs

See Also:
Constant Field Values

SAUCE_BROWSER_PROPERTY

public static final String SAUCE_BROWSER_PROPERTY

Saucelabs browser, default is Firefox.

See Saucelabs Resources

-Dsaucelabs.browser=

See Also:
Constant Field Values

SAUCE_BUILD_PROPERTY

public static final String SAUCE_BUILD_PROPERTY

Suacelabs build displayed as saucelabs build, default is unknown.

-Drice.version=

See Also:
Constant Field Values

SAUCE_DOWNLOAD_SCRIPT_PROPERTY

public static final String SAUCE_DOWNLOAD_SCRIPT_PROPERTY

Create a unix shell script to download saucelab resources, default is false.

Note - saucelabs history only goes back so far, if you run enough tests the resources will no longer be available for downloading.

-Dsaucelabs.download.script=false

See Also:
Constant Field Values

SAUCE_IDLE_TIMEOUT_SECONDS_PROPERTY

public static final String SAUCE_IDLE_TIMEOUT_SECONDS_PROPERTY

Saucelabs idle timeout in seconds, default is 180.

-Dsaucelabs.idle.timeout.seconds=

See Also:
Constant Field Values

SAUCE_KEY_PROPERTY

public static final String SAUCE_KEY_PROPERTY

Saucelabs key, required.

-Dsaucelabs.key=

See Also:
Constant Field Values

SAUCE_MAX_DURATION_SECONDS_PROPERTY

public static final String SAUCE_MAX_DURATION_SECONDS_PROPERTY

Saucelabs max duration in seconds, default is 480.

-Dsaucelabs.max.duration.seconds=

See Also:
Constant Field Values

SAUCE_PLATFORM_PROPERTY

public static final String SAUCE_PLATFORM_PROPERTY

Saucelabs platform (OS) replace spaces with underscores, default is Linux.

See Saucelabs Resources

-Dsaucelabs.platform=

See Also:
Constant Field Values

SAUCE_IE_INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS_PROPERTY

public static final String SAUCE_IE_INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS_PROPERTY

Saucelabs ignore security domains in IE, which can introduce flakiness, default is true.

See InternetExplorerDriver FAQ

-Dsaucelabs.ie.ignore.domains=false

See Also:
Constant Field Values

SAUCE_POPUP_PROPERTY

public static final String SAUCE_POPUP_PROPERTY

Saucelabs popup disable setting, default is false (not disabled).

See DISABLE POPUP HANDLER

-Dsaucelabs.pop.disable=

See Also:
Constant Field Values

SAUCE_SHARE_PROPERTY

public static final String SAUCE_SHARE_PROPERTY

Saucelabs share setting, default is public restricted.

See Job Sharing. Valid values are: public, public restricted, team, share, and private.

-Dsaucelabs.share=

See Also:
Constant Field Values

SAUCE_USER_PROPERTY

public static final String SAUCE_USER_PROPERTY

Saucelabs user, required.

-Dsaucelabs.user=

See Also:
Constant Field Values

SAUCE_VERSION_PROPERTY

public static final String SAUCE_VERSION_PROPERTY

Saucelabs browser Version, required.

See Saucelabs Resources 0 or null is current version of Chrome. If using a browser other than Chrome this must be set else an Exception will be thrown.

-Dsaucelabs.version=

See Also:
Constant Field Values

SAUCE_REST_API_DELAY_MS

public static final String SAUCE_REST_API_DELAY_MS

Saucelabs REST API delay in milliseconds, default is 5000.

-Dsaucelabs.rest.api.delay.ms=

See Also:
Constant Field Values

authentication

public com.saucelabs.common.SauceOnDemandAuthentication authentication

Constructs a SauceOnDemandAuthentication instance using the supplied user name/access key.

To use the authentication supplied by environment variables or from an external file, use the no-arg SauceOnDemandAuthentication constructor.

SAUCE_USER_PROPERTY SAUCE_KEY_PROPERTY

Constructor Detail

SauceLabsWebDriverHelper

public SauceLabsWebDriverHelper()
Method Detail

setUp

public void setUp(String className,
                  String testName)
           throws Exception

Saucelabs setUp.

Creates a RemoteWebDriver instance with the DesiredCapabilities as configured using the JVM arguments described as SAUCE_ Constants in this class. After setUp the WebDriver can be accessed via getDriver(). You'll also need getSessionId() for when you call tearDown(boolean, java.lang.String, java.lang.String, java.lang.String)

Parameters:
className - class name of the test being setup as a String
testName - test name of the test being setup as a String
Throws:
Exception

tearDown

public void tearDown(boolean passed,
                     String sessionId,
                     String className,
                     String testName)
              throws Exception

Saucelabs tearDown, flag the tests as passed or failed.

Uses the SauceREST API to register a test as passed or failed. SAUCE_REST_API_DELAY_MS

Parameters:
passed - true if passed, falsed if failed, as a boolean
sessionId - saucelabs test session id, as a String
Throws:
Exception

getDriver

public org.openqa.selenium.WebDriver getDriver()

Returns the (RemoteWebDriver) driver.

Returns:
WebDriver

getSessionId

public String getSessionId()
Specified by:
getSessionId in interface com.saucelabs.common.SauceOnDemandSessionIdProvider


Copyright © 2005–2014 The Kuali Foundation. All rights reserved.