|Table of Contents|
The implicitly wait method tells the browser to wait a set amount of time (in seconds) for elements to appear on the page before giving up. Without it, slow loading DOMs could cause our tests to fail when they might otherwise pass. Using implicit waits is one of our recommended best practices.
Analyzing the Code
If you look at the code closely, you'll see that basics for setting up a test to run on sauce are very straightforward, and really only require two elements.
Running the Example Code
- Copy the example code and save it into a file called
Make sure your username and access key are included in the URL passed through to the command_executor.
- Open terminal and navigate to the directory where the file is located.
Execute the test:
Check your dashboard and you will see that your test has just run on Sauce!
Running Tests Against Local Applications
If your test application is not publicly available, you will need to use Sauce Connect so that Sauce can reach it.
Sauce Connect is a tunneling app that allows you to execute tests securely when testing behind firewalls or on localhost. For more detailed information, please visit see the Sauce Connect docs.
Reporting to the Sauce Labs Dashboard
Running Tests in Parallel
You can clone this script from the
saucelabs-training repository on GitHub: https://github.com/saucelabs-training/demo-python
There are examples using both
Testing with a Proxy
If you're trying to run this script from behind a VPN or a corporate proxy, you must use either IPSec or Sauce Connect Proxy. Once you've downloaded and installed the relevant software, add the following capability to the test script:
Running the Test
Navigate to the root project directory and use
pipto install the latest Selenium library for use in the script:
$ pip install -r requirements.txt
- Set your Sauce Labs Credentials as envrionment variables, indicated by the following lines in the script:
View Git file path on-boarding-modules/pytest-examples/test_module4_pytest.py lastline 9 repository-id 36 firstline 8 branch refs/remotes/origin/master
Depending on which framework you're using, your commands may be different to run the tests. Use any of the following command based on the chosen framework:
python -m unittest on-boarding-modules/unittest-examples/test_module4_unittest.py