A minimal example repo showing how to run Robot Framework Selenium tests on BrowserStack Automate, with optional visual testing using Percy (Percy on Automate).
It includes sample Robot tests, a BrowserStack config file (browserstack.yml), and the commands needed to run tests via browserstack-sdk and percy exec.
python3 should be installed
- Clone the repo
git clone -b sdk https://github.com/browserstack/robot-browserstack.git - It is recommended to use a virtual environment to install dependencies. To create a virtual environment:
python3 -m venv env source env/bin/activate # on Mac env\Scripts\activate # on Windows - Install dependencies
pip install -r requirements.txt
-
Add your BrowserStack username and access key in the
browserstack.ymlconfig fle. -
You can also export them as environment variables,
BROWSERSTACK_USERNAMEandBROWSERSTACK_ACCESS_KEY:export BROWSERSTACK_USERNAME=<browserstack-username> export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>set BROWSERSTACK_USERNAME=<browserstack-username> set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> setx BROWSERSTACK_USERNAME=<browserstack-username> setx BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
- To run sample tests:
- To run the sample tests in parallel across the platforms defined in the
browserstack.ymlfile, run:browserstack-sdk robot ./tests/test-1.robot
- To run the sample tests in parallel across the platforms defined in the
The repository can be run through Percy to capture visual snapshots in your BrowserStack Automate runs.
-
Install Percy CLI (recommended global install):
npm install -g @percy/cli -
Install Percy SDK for Selenium (required for Percy snapshots):
pip install percy-selenium -
Export your Percy token (from your Percy project settings):
export PERCY_TOKEN="<your token here>" -
Run your Robot Framework tests through Percy:
npx percy exec --verbose -- browserstack-sdk robot ./tests/test-1.robot
Note: Percy snapshots are captured using
percy_screenshotfrompercy_selenium. For Python-based Selenium tests, you can addfrom percy import percy_screenshotand callpercy_screenshot(driver, name="...")in your test script. For Robot Framework tests, add a corresponding keyword in your test library that calls into the Percy SDK.
Understand how many parallel sessions you need by using our Parallel Test Calculator
