This script illustrates the basic set up of a test that runs in the Sauce Labs virtual browser cloud. It includes using environment variables for authentication credentials, using tags and build numbers for test result management, and reporting the Pass/Fail status of the test to the Sauce Labs dashboard.
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 Sauce Labs account
- 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
Setup Example Script
When this script runs, it opens the browser specified in the script, navigates to the saucelabs.demo web app, and then closes the browser. If you want to run this script using your Sauce Labs credentials and have it navigate to your own web app:
- Follow the instructions in Best Practice: Use Environment Variables for Authentication Credentials to set up your Sauce Labs account access.
- Enter the URL for the web app you want to test in the place of
- Once you've been able to run the test against your web app, you can use the Platform Configurator to experiment with changing the desired capabilities of the test.
Clone this script from the saucelabs-training GitHub repo: https://github.com/saucelabs-training/demo-csharp/blob/master/SauceExamples/Web.Tests/OnboardingTests/InstantSauceTest4.cs