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.
- You should have a Sauce Labs account
- You should have a Selenium environment with the bindings for Python set up on the local machine where you'll launch your tests. If you need help with this, check out the ReadMe in the Python example scripts repository on GitHub.
- You should read the Best Practices for Running Tests
You will need to install the Selenium WebDriver client driver to your local Python environment
You can either download the driver from the link, or use
pipto install it.
You can also optionally install the Sauce Python client, which provides features for reporting job information to the Sauce Labs dashboard.
Setup Example Script
The sample test opens the browser, navigates to the saucelabs.demo web app, and then closes the browser.
To run this script against your own app using your Sauce Labs credentials:
- Set your authentication credentials as environment variables to connect the test to your Sauce Labs account.
- 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, check out the Platform Configurator to see more of the desired capabilities you can use when testing with Sauce.
Clone this script from the saucelabs-training GitHub repo: https://github.com/saucelabs-training/demo-python/blob/master/pytest/instant-sauce-pytest4.py