This script provides an example of how you might configure your own automated tests to run in the Sauce Labs browser cloud. The sample test uses environment variables for authentication, assigns a tag and build number for test result management, and reports Pass/Fail status 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.
What You'll Need
- 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 may also need to install the sauce_whisk gem to report the results of your test to your Sauce Labs dashboard
The script below navigates to our sample application, enters login credentials, and successfully clicks the login button.
- Global Dependencies
Navigate to the `rspec` directory (`/selenium-examples/rspec/`)
Install the gem packages
Running the Tests
Run tests in parallel on default configuration:
Run in parallel on a specific configuration (see /spec/Rakefile` for available tasks)
Run Sauce Labs Demo, then watch your tests run in the Test Results page in Sauce Labs: