- 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
With Sauce Labs you can run automated tests of your web apps against a wide variety of device/operating system/browser combinations. This topic will provide you with basic information and code examples to get your Ruby tests up and running on Sauce.
The code in this topic is presented as an example only, since your tests and testing environments may require specialized scripting. This information should be taken only as an illustration of how you could set up your tests with Sauce Labs, and is not directly supported by Sauce.
- You should have a Selenium environment with the Ruby bindings set up on a local machine where you'll launch your tests. If you need help with setting this up, check out the ReadMe in the Ruby sample script repository on GitHub.
- You should read the Best Practices for Running Tests with Sauce
- Make sure you have the selenium-webdriver gem installed
- If you want to run tests in parallel you will need the parallel_tests gem
- You will also need to install the sauce_whisk gem to report the results of your test to your Sauce Labs dashboard
It's very easy to get your existing Ruby tests up and running on Sauce.
If you wanted to run a Selenium test on Selenium locally, you would initiate a driver for the browser you want to test against like this. To run a test on a remote service like Sauce Labs, all you need to change is your To find your Sauce Labs access key: IP Ranges and Data Center Endpoints Virtual Device Cloud: https://ondemand.eu-central-1.saucelabs.com/wd/hub Once you have your tests set up to run in the Sauce cloud, you need to define the platform, browser, and version you want the test to run against, which is where You can manually enter the values you want for
Set Sauce URL and Access Credentials
driver definition, and make sure that the
sauce_endpoint variable includes your Sauce
You will use this same username in your test script.
Sauce Labs has data centers in both the US and EU. You can access Sauce Labs services from either location by providing the appropriate URL endpoints, and whitelisting their associated IP ranges.
Sauce Connect Proxy: https://eu-central-1.saucelabs.com/rest
REST API: https://eu-central-1.saucelabs.com/rest/v1
22.214.171.124/21 (this is equivalent to the range
126.96.36.199 – 188.8.131.52)
184.108.40.206/21 (this is equivalent to the range
220.127.116.11 - 18.104.22.168)
Set Desired Capabiliites
caps come into play.
:version, or you can use the handy Platform Configurator to generate the
caps values for any combination of platform, browser, and browser version.
If you wanted to run a Selenium test on Selenium locally, you would initiate a driver for the browser you want to test against like this.
To run a test on a remote service like Sauce Labs, all you need to change is your
To find your Sauce Labs access key:
IP Ranges and Data Center Endpoints
Virtual Device Cloud: https://ondemand.eu-central-1.saucelabs.com/wd/hub
Once you have your tests set up to run in the Sauce cloud, you need to define the platform, browser, and version you want the test to run against, which is where
You can manually enter the values you want for
Running Local Tests
Running Tests in Parallel
You can run your tests in parallel at two levels, and you can run your tests in parallel across multiple browsers. For example, if you have 10 tests and want to run on five browsers, this would be parallelism of five. You can also run tests across browsers and each test in parallel. Using our previous example this would be more like 50 parallel tests. Doing this requires that your tests are written in a way that they do not collide with one another, as described in our Best Practice topics avoiding external test dependencies and avoiding dependencies between tests.
Match Thread Count to Concurrency Limit
You should match your thread count to your concurrency limit, which is shown in the My Account section of your user profile information on the Sauce Labs dashboard.
For more information, check out the example scripts in our GitHub repo.
Reporting on Test Results
The Job ID is the simplest part of the process. The ID assigned to each job by Sauce Labs is the same as the Session ID for the corresponding Selenium session, which you can pull off the driver like so:
Using the REST API is best done with the sauce_whisk gem, which assumes you've set your Sauce username and access key as the
SAUCE_ACCESS_KEY environment variables.
This example shows how you would modify the example RSpec
spec_helper.rb file to check the status of the test, and pass that to the REST API.
That's it! Your tests will now be reporting their status to the Sauce Labs REST API.