Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

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.

Terminal
Copy icon Copy

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:

Terminal
Copy icon Copy

Modify or create tests

Below is a complete pytest example that connects to a BrowserStack Android device, opens a browser, and runs a test.

test_basic_playwright.py
Copy icon Copy

Run your test

Once the setup is complete, run your test using pytest from the command line.

Terminal
Copy icon Copy

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





Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle