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-headless Run browser in headless mode True
--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
--pw-debug Enable Playwright debug mode by setting PWDEBUG=1 False
--pw-open-last-trace Open the last captured Playwright trace after the test run False

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.2.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

vedro_pw-0.2.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vedro_pw-0.2.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for vedro_pw-0.2.1.tar.gz
Algorithm Hash digest
SHA256 05e4388dad631d6e73b7d45dc2d4022572ba704fc3421e3b2d6a78335e1def78
MD5 93768106c05769e23d8c6464fbca6ef8
BLAKE2b-256 190d01050fc32abe31c3266e0131ef78cce65b540e1f6c1e22b105cdfc0e1356

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vedro_pw-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for vedro_pw-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca0c0cd08a47fabc76d75acea93a06da64792b144e98cccc811162932e027712
MD5 fa9126b4cb30bdcd4ee33a946817af9f
BLAKE2b-256 1cf56515a56637bb9e5f8dd3c651e856f71af3c1511627be528d9d3170b5ad13

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