Skip to main content

After this course i will be a decent playwright and pytest developer

Project description

Playwright and Pytest

Install Pytest Plugin

pip install pytest-playwright

Install the required browsers

playwright install

test_example.py

test example

Running the Example Test

pytest

Using Test Hooks

import pytest
from playwright.sync_api import Page, expect

@pytest.fixture(scope="function", autouse=True)
def before_each_after_each(page: Page):
    
    print("before the test runs")

    # Go to the starting url before each test.
    page.goto("https://playwright.dev/")
    yield
    
    print("after the test runs")

def test_main_navigation(page: Page):
    # Assertions use the expect API.
    expect(page).to_have_url("https://playwright.dev/")

Running tests headed

pytest --headed

Running tests on different browsers and multiple browser

pytest --browser webkit
pytest --browser webkit --browser firefox

Running specific tests

pytest test_login.py

To run a set of test files pass in the names of the test files that you want to run.

pytest tests/test_todo_page.py tests/test_landing_page.py

To run a specific test pass in the function name of the test you want to run.

pytest -k test_add_a_todo_item

Run tests in Parallel

pytest --numprocesses 2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

playwright_project-0.0.5.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playwright_project-0.0.5-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file playwright_project-0.0.5.tar.gz.

File metadata

  • Download URL: playwright_project-0.0.5.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.6 Windows/10

File hashes

Hashes for playwright_project-0.0.5.tar.gz
Algorithm Hash digest
SHA256 b88285dfc1393e80e6b5dcfe3b93fa99f951d971653ebe452427f58a01fb6d5a
MD5 9245eaf8b541749b3725de96cc0c2d09
BLAKE2b-256 e1d9f80327829a2b8567fed987eba4510e774ef3437d613d10ebe1a55f296fd8

See more details on using hashes here.

File details

Details for the file playwright_project-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_project-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6d33da96b4d03f6635fd7aae0cad7d368f27192700433818046578896c6dfec6
MD5 55700b36bc1ff4f5f6743c74766c7173
BLAKE2b-256 d9ec4265af2c33bc2e86c43930503dc54b29b6742907f5f78d4b15d7d2506cfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page