Skip to main content

Integrates Playwright for automated browser testing with customizable configuration options

Project description

vedro-pw

Codecov PyPI PyPI - Downloads Python Version

The vedro-pw plugin allows you to use Playwright within your Vedro scenarios for end-to-end testing of web applications.

Installation

Quick

For a quick installation, you can use a plugin manager as follows:

$ vedro plugin install vedro-pw

Manual

To install manually, follow these steps:

  1. Install the package using pip:
$ pip3 install vedro-pw
  1. Next, activate the plugin in your vedro.cfg.py configuration file:
# ./vedro.cfg.py
import vedro
import vedro_pw


class Config(vedro.Config):
    class Plugins(vedro.Config.Plugins):
        class Playwright(vedro_pw.Playwright):
            enabled = True

Usage

Use the provided context functions in your scenarios to interact with Playwright:

  • launched_browser: Launches a local or remote browser based on the configuration.
  • created_browser_context: Creates a new browser context.
  • opened_browser_page: Opens a new page in the browser context.

Basic Example

Here's a simple Vedro scenario that opens the Playwright homepage and verifies the page title.

import vedro
from vedro_pw import opened_browser_page

class Scenario(vedro.Scenario):
    subject = "Open Playwright homepage"

    async def given(self):
        self.page = await opened_browser_page()

    async def when(self):
        await self.page.goto("https://playwright.dev/")

    async def then(self):
        assert await self.page.title() == "Playwright"

Command-Line Options

The plugin adds several command-line arguments for flexibility:

Option Description Default
--pw-browser Browser to use (chromium, firefox, webkit) chromium
--pw-headed Run browser in headed mode False
--pw-slowmo Delay operations by specified milliseconds 0
--pw-remote Connect to a remote browser instance False
--pw-remote-endpoint WebSocket endpoint for remote browser ws://localhost:3000
--pw-screenshots Screenshot capturing (always, on-failure, on-reschedule, never) never
--pw-video Video recording (always, on-failure, on-reschedule, never) never
--pw-trace Trace recording (always, on-failure, on-reschedule, never) never
--pw-device Emulate a specific device None

Example Usage

$ vedro run --pw-browser=firefox --pw-headed --pw-screenshots=on-failure --save-artifacts

Capture Modes

CaptureMode determines when to capture artifacts:

  • never: Do not capture.
  • on-failure: Capture only when a scenario fails.
  • on-reschedule: Capture when a scenario is rescheduled.
  • always: Always capture.

Artifacts like screenshots, videos, and traces are attached to the scenario results and can be used in reports.

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

vedro_pw-0.1.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

vedro_pw-0.1.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file vedro_pw-0.1.2.tar.gz.

File metadata

  • Download URL: vedro_pw-0.1.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for vedro_pw-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0bb4edf52fefcda6a0d4bd819af3b3c16af8b3356492ef471789c515a52c80db
MD5 43b26e8bef9c9e52678db6f9f1e78ef7
BLAKE2b-256 2749eb96f90e6ee8c0805215e13d6c10c47e011b5116ea2989335d29daeac05f

See more details on using hashes here.

File details

Details for the file vedro_pw-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: vedro_pw-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for vedro_pw-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e19f15de511f851dfc4a63028500d50c4af73d0cbfd846423cbb9070dcd14182
MD5 ccfa9cced7d45d7038585b7d7d2867b2
BLAKE2b-256 dcd928d1b538f7e76f1a263aa2c25739adcc7ed847f503bcb4b6151b2a65a197

See more details on using hashes here.

Supported by

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