This page provides a walkthrough on how to run Playwright tests locally and on Sauce Labs.
- A Sauce Labs account (if you don't have one, start a free trial)
- Download and install
- Ensure you've met the prerequisites outlined in the Testrunner Toolkit documentation
Before you begin running playwright tests, you must configure
Configure your Sauce Labs credentials:
via system environment variables:bash exampleexport SAUCE_USERNAME=<your sauce labs username>export SAUCE_ACCESS_KEY=<your sauce labs access key>
saucectl configure:saucectl configure
This command generates a
credentials.ymlfile:example credentials.ymlusername: <your saucelabs username>accessKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxsource: saucectl configure
Do NOT commit
It should go without saying, but do not publicly expose your
credentials.ymlfile over the internet. Make sure you add this file to your
.gitignorefile, as you should only use it locally.
Playwrightframework. This command generates the default
tests/playwrightdirectory, and an example playwright test:INF Start New CommandChoose a framework:Puppeteer❯ PlaywrightTestcafeCypress
Want to use your existing Playwright tests?
If you have existing Playwright tests,
saucectlprompts you to overwrite your
tests/playwright/directory, and other relevant test configuration files.
If you want to edit the configuration manually select "No" and visit the configuration documentation for more details.
Choose a Sauce Labs data center location:INF Start New CommandChoose a framework: PlaywrightChoose the sauce labs region:❯ us-west-1eu-central-1
The following steps outline how to run your playwright tests on your local machine with the containerized solution, Testrunner Toolkit:
Run your playwright tests using
dockermode by modifying
config.ymllike following:defaults:mode: docker
orsuites:- name: saucy testmode: docker
The test results display in the console like so:Run ./saucectl run -c ./.sauce/config.yml00:14:19 INF Running version 0.30.000:14:19 INF Reading config file config=./.sauce/config.yml00:14:19 INF Running Playwright in Docker⠋ Pulling image saucelabs/stt-playwright-node:v1.7.400:15:42 INF Launching workers. concurrency=100:15:42 INF Setting up test environment suite="saucy test"00:15:42 INF File mounted from=tests/playwright/ suite="saucy test" to=/home/seluser/playwright00:15:42 INF Using credentials set by environment variables suite="saucy test"........00:15:50 INF Starting container id=91afa3083b77 img=saucelabs/stt-playwright-node:v1.7.4 suite="saucy test".........00:15:59 INF Tearing down environment suite="saucy test"
You can also troubleshoot any issues with the --verbose flag.
A Sauce Labs job link appears in the console where you can verify the results in the Sauce Labs dashboard:00:16:00 INF Suites completed: 1/100:16:00 INF Suite finished. passed=true suite="saucy test"url=https://app.saucelabs.com/tests/8f332330914d431cb0fe9191615cb14400:16:00 INF Suites expected: 100:16:00 INF Suites passed: 100:16:00 INF Suites failed: 0
The following steps outline how to run your playwright tests using Sauce Labs virtual machines:
Run your playwright tests with the following
orsuites:- name: saucy testmode: sauce
For more information regarding the
saucectlparameters, including how to increase your VM concurrency, please visit the configuration documentation.
Watch test runs in real-time, or verify the results in the Sauce Labs dashboard:
Running Tests with a Local App
If you plan to run your playwright tests with either of the following scenarios:
localhostapp running on your host machine
- An app running locally in a CI pipeline
- An app running on a local app server in a private network
Please review the following documentation section for further details.
Below are some additional topics related to using Playwright with Sauce Labs.
Please visit the Configuration page to learn more about
config.yml and the specific fields and properties:
Please visit our CI integrations page for more information about how to run your tests in the following CI platforms: