Integrates Playwright for automated browser testing with customizable configuration options
Project description
vedro-pw
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:
- Install the package using pip:
$ pip3 install vedro-pw
- 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 |
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
Built Distribution
File details
Details for the file vedro_pw-0.2.0.tar.gz
.
File metadata
- Download URL: vedro_pw-0.2.0.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9323f2bcefba4e8248f71aa013f07dd78b3043fea46ee5c206cf3eb486f22c7b |
|
MD5 | 4c664c574af7f97c7f9c88677d68922f |
|
BLAKE2b-256 | 35fb191fd762647511606ea932eb8f777b17f88f26cfd886d3eb3b37d0a479f3 |
File details
Details for the file vedro_pw-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: vedro_pw-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3f971591f27a424df9a7f0958cf51ead7395ffa3abd4843ae9c2e1ed6dc3cda |
|
MD5 | 86c48115c317cc3a00113bac18875fe7 |
|
BLAKE2b-256 | 594b2f7a2db14aa67b610c30275bd2239adc405c538207380f890e74182cb728 |