Skip to main content

Running tests

You can run a single test, a set of tests or all tests. Tests can be run on one browser or multiple browsers. By default tests are run in a headless manner meaning no browser window will be opened while running the tests and results will be seen in the terminal. If you prefer you can run your tests in headed mode by using the --headed flag.

  • Running tests on Chromium

  • Running a single test file

  • Run a set of test files

    pytest tests/todo-page/ tests/landing-page/
  • Run the test with the function name

    pytest -k "test_add_a_todo_item"
  • Running tests in headed mode

    pytest --headed
  • Running Tests on specific browsers

    pytest --browser webkit
  • Running Tests on multiple browsers

    pytest --browser webkit --browser firefox
  • Running Tests in parallel

    pytest --numprocesses auto

    (This assumes pytest-xdist is installed. For more information see here.)

For more information see Playwright Pytest usage or the Pytest documentation for general CLI usage.

Running Tests

Since Playwright runs in Python, you can debug it with your debugger of choice with e.g. the Python extension in Visual Studio Code. Playwright comes with the Playwright Inspector which allows you to step through Playwright API calls, see their debug logs and explore locators.

PWDEBUG=1 pytest -s
Playwright Inspector

Check out our debugging guide to learn more about the Playwright Inspector as well as debugging with Browser Developer tools.

What's Next