- The Platform Configurator
- Getting Started with Selenium for Automated Website Testing
- Getting Started with Appium for Mobile Native Application Testing
- Selenium Bootcamp by Dave Haeffner
- Appium Bootcamp by Dave Haeffner and Matthew Edwards
The Sauce plugin for Jenkins provides an easy way for you to populate the desired capabilities for operating system and browser combinations for your tests as environment variables, rather than needing to hardcode them into your tests. This is a best practice for automated testing, since it means you can use your tests with multiple operating system/browser combinations without having to rewrite your test.
- If you haven't enabled the Sauce plugin for Jenkins yet, you should follow the instructions in Installing and Configuring the Sauce OnDemand Plugin for Jenkins.
Overriding the Environment Variables for Authentication
If you want to override the default global authentication credentials that you set as environment variables when you configured the plugin, select Override default authentication in the Build Environment section of the project configuration page. After you select this option, enter the authentication credentials you want to use for the project.
Setting Desired Capabilities for Your Project
- In Jenkins, go to your project.
- In the left-hand navigation, select Configure.
- In the Sauce Labs Options section, select the browser automation tool you want to use, for example WebDriver.
When you select a browser automation tool, it will open up a menu of operating system and browser combinations that you can test against with that tool.
- Select the the operating systems and browsers you want to test against.
Select Use latest version of selected browsers to default to the latest version of the browsers you select.
- If you select a single operating system/browser combination, then the environment variables
SELENIUM_BROWSERwill be populated with your selections. If you select a mobile operating system/browser, the variables
SELENIUM_DEVICE_TYPEwill be populated.
If you select multiple OS/browser combinations, the
SAUCE_ONDEMAND_BROWSERSenvironment variable will be populated with a JSON-formatted string containing the attributes of the selected browsers, as shown in this example:
Setting Up Your Tests to Use the Environment Variables
In your test script, you reference the environment variables as part of your desired capabilities. Though the exact syntax will vary depending on your scripting language, this example illustrates the way you would reference the environment variables
SELENIUM_PLATFORM in your test script.
This example is for a single operating system/browser combination. If you have multiple selections, you can load the JSON string for the
SAUCE_ONDEMAND_BROWSERS environment variable by using the JSON library for your scripting language, and then loop through the string to send the various combinations to your test framework.
You can find a full list of the available environment variables in the topic Environment Variables Used by the Jenkins Plugin.