-
Notifications
You must be signed in to change notification settings - Fork 192
Integration with Cloud Services
BrowserStack, LambdaTest and Sauce Labs are the most popular cloud service providers for running Selenium and Appium tests. Our framework integrates with all of them.
To run test on cloud service provider like BrowserStack, LambdaTest and SauceLab, you need to create .env.remote file with REMOTE_BROWSER_PLATFROM, REMOTE_USERNAME, REMOTE_ACCESS_KEY parameter under root of repository. Refer env_remote file in our framework for more details, you can rename it to .env.remote also.
#Set REMOTE_BROWSER_PLATFROM TO BS TO RUN ON BROWSERSTACK else
#SET REMOTE_BROWSER_PLATFORM TO SL TO RUN ON SAUCELABS
#SET REMOTE_BROWSER_PLATFORM TO LT TO RUN ON LAMBDATEST
REMOTE_BROWSER_PLATFORM = "Select remote platform"
REMOTE_USERNAME = "Enter your username"
REMOTE_ACCESS_KEY = "Enter your access key"
To run your automated tests using BrowserStack, you must provide a valid username, access key, and set parameter REMOTE_BROWSER_PLATFROM = "BS"
. These parameters are fetched from .env.remote file as an environment variable. Refer env_remote file in our framework and above setup section.
Refer to our post on Get started with BrowserStack if you are new to BrowserStack.
We configured pytest to run tests on BrowserStack by providing fixtures for command line parameters like the browser, the browser version, the operating system, the operating system version. These fixtures are stored in conftest.py file as shown below.
@pytest.fixture
def remote_flag(request):
"pytest fixture for browserstack/sauce flag"
try:
return request.config.getoption("--remote_flag")
except Exception as e:
print("Exception when trying to run test: %s"%__file__)
print("Python says:%s"%str(e))
Every time pytest sees the browser as the test function parameter, it executes the pytest fixture. This fixture checks if any command line parameter has been provided. If no option is given, pytest uses the default option that was mentioned when the option was added.
You can follow the step by step guide and the detailed code samples given in our post How to configure py.test to work with BrowserStack for configuring py.test to work with BrowerStack.
In case you want to run the test in remote, use command line option '--remote_flag' in the pytest. For Example:- If you want to run example test shown above on OS X Yosemite using a Chrome browser use the below command:
python -m pytest --browser chrome --ver 90 --os_name "OS X" --os_version Yosemite --remote_flag y
In case you want to run the Mobile test with Browserstack, use the command as below:
pytest -k test_mobile_bitcoin_price --mobile_os_name Android --mobile_os_version 8.0 --device_name "Google Pixel" --app_path "/Users/apple/Downloads/" --remote_flag y
In case you want to run automated tests using Sauce Labs, you can set "REMOTE_BROWSER_PLATFROM" = "SL"
, valid username, access_key under .env.remote file. Refer above setup section for more details.
You can also configure pytest to run tests on Sauce Labs. You can simply add details like the browser, the browser version, the operating system, the operating system version as command line parameters to pytest.
pytest --browser chrome --ver 90 --remote_flag y
For more details, refer our blog posts Running Selenium automation using Sauce Labs: Part 1,Part 2 and Part 3
In case you want to run automated tests using LambdaTest, you can set "REMOTE_BROWSER_PLATFROM" = "LT"
, valid username, access_key under .env.remote file. Refer above setup section for more details.
You can also configure pytest to run tests on LambdaTest. You can simply add details like the browser, the browser version, the operating system, the operating system version as command line parameters to pytest.
pytest --browser chrome --ver 90 --remote_flag y