playwright-project 0.0.5

Last updated:

0 purchases

playwright-project 0.0.5 Image
playwright-project 0.0.5 Images
Add to Cart

Description:

playwrightproject 0.0.5

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

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.