Run Python Playwright-Android tests on BrowserStack Automate
Install playwright-browserstack, connect a pytest test to a real Android device, and view the results on the Automate dashboard.
This guide shows you how to run your Python Playwright tests on BrowserStack real Android devices using Automate.
Running Playwright Android tests with Python requires playwright-browserstack version 1.62.0 or later. Install the latest version of playwright-browserstack to avoid build issues during installation.
Prerequisites
- BrowserStack Username and Access key. You can find this in your account profile. If you have not created an account yet, you can sign up for a Free Trial.
- Python 3.10 or later is installed on your machine.
-
pip, the Python package manager, is installed and up to date.
Perform the following steps to run a Playwright-Android test:
Install dependencies
Create and activate a fresh virtual environment, then use pip to install the playwright-browserstack package and pytest, the test runner used in this guide.
On Windows, run .venv\Scripts\activate instead of source .venv/bin/activate.
Donβt install Microsoftβs playwright package in the same environment. If Playwright stops importing after you uninstall playwright, run pip install --force-reinstall --no-deps playwright-browserstack.
Set your credentials securely
The sample test reads your BrowserStack credentials from environment variables. Run the following commands to set them:
Modify or create tests
Below is a complete pytest example that connects to a BrowserStack Android device, opens a browser, and runs a test.
View your results
After execution, you can view the test results, including a video recording and logs, on the Automate dashboard.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!