# vedro-pw
[](https://codecov.io/gh/vedro-universe/vedro-pw)
[](https://pypi.python.org/pypi/vedro-pw/)
[](https://pypi.python.org/pypi/vedro-pw/)
[](https://pypi.python.org/pypi/vedro-pw/)
The `vedro-pw` plugin allows you to use [Playwright](https://playwright.dev/) within your [Vedro](https://vedro.io/) scenarios for end-to-end testing of web applications.
## Installation
<details open>
<summary>Quick</summary>
<p>
For a quick installation, you can use a plugin manager as follows:
```shell
$ vedro plugin install vedro-pw
```
</p>
</details>
<details>
<summary>Manual</summary>
<p>
To install manually, follow these steps:
1. Install the package using pip:
```shell
$ pip3 install vedro-pw
```
2. Next, activate the plugin in your `vedro.cfg.py` configuration file:
```python
# ./vedro.cfg.py
import vedro
import vedro_pw
class Config(vedro.Config):
class Plugins(vedro.Config.Plugins):
class Playwright(vedro_pw.Playwright):
enabled = True
```
</p>
</details>
## 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.
```python
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
```shell
$ 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/vedro-universe/vedro-pw",
"name": "vedro-pw",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Nikita Tsvetkov",
"author_email": "tsv1@fastmail.com",
"download_url": "https://files.pythonhosted.org/packages/06/4f/97c47e9139a4e825d17effd2c8cf59f8c124d05d0ad2d11e63c78b0a2484/vedro_pw-0.3.0.tar.gz",
"platform": null,
"description": "# vedro-pw\n\n[](https://codecov.io/gh/vedro-universe/vedro-pw)\n[](https://pypi.python.org/pypi/vedro-pw/)\n[](https://pypi.python.org/pypi/vedro-pw/)\n[](https://pypi.python.org/pypi/vedro-pw/)\n\nThe `vedro-pw` plugin allows you to use [Playwright](https://playwright.dev/) within your [Vedro](https://vedro.io/) scenarios for end-to-end testing of web applications.\n\n## Installation\n\n<details open>\n<summary>Quick</summary>\n<p>\n\nFor a quick installation, you can use a plugin manager as follows:\n\n```shell\n$ vedro plugin install vedro-pw\n```\n\n</p>\n</details>\n\n<details>\n<summary>Manual</summary>\n<p>\n\nTo install manually, follow these steps:\n\n1. Install the package using pip:\n\n```shell\n$ pip3 install vedro-pw\n```\n\n2. Next, activate the plugin in your `vedro.cfg.py` configuration file:\n\n```python\n# ./vedro.cfg.py\nimport vedro\nimport vedro_pw\n\n\nclass Config(vedro.Config):\n class Plugins(vedro.Config.Plugins):\n class Playwright(vedro_pw.Playwright):\n enabled = True\n```\n\n</p>\n</details>\n\n## Usage\n\nUse the provided context functions in your scenarios to interact with Playwright:\n\n- `launched_browser`: Launches a local or remote browser based on the configuration.\n- `created_browser_context`: Creates a new browser context.\n- `opened_browser_page`: Opens a new page in the browser context.\n\n### Basic Example\n\nHere's a simple Vedro scenario that opens the Playwright homepage and verifies the page title.\n\n```python\nimport vedro\nfrom vedro_pw import opened_browser_page\n\nclass Scenario(vedro.Scenario):\n subject = \"Open Playwright homepage\"\n\n async def given(self):\n self.page = await opened_browser_page()\n\n async def when(self):\n await self.page.goto(\"https://playwright.dev/\")\n\n async def then(self):\n assert await self.page.title() == \"Playwright\"\n```\n\n## Command-Line Options\n\nThe plugin adds several command-line arguments for flexibility:\n\n| Option | Description | Default |\n|------------------------|-------------------------------------------------------------------------|-----------------------|\n| `--pw-browser` | Browser to use (`chromium`, `firefox`, `webkit`) | `chromium` |\n| `--pw-headed` | Run browser in headed mode | `False` |\n| `--pw-headless` | Run browser in headless mode | `True` |\n| `--pw-slowmo` | Delay operations by specified milliseconds | `0` |\n| `--pw-remote` | Connect to a remote browser instance | `False` |\n| `--pw-remote-endpoint` | WebSocket endpoint for remote browser | `ws://localhost:3000` |\n| `--pw-screenshots` | Screenshot capturing (`always`, `on-failure`, `on-reschedule`, `never`) | `never` |\n| `--pw-video` | Video recording (`always`, `on-failure`, `on-reschedule`, `never`) | `never` |\n| `--pw-trace` | Trace recording (`always`, `on-failure`, `on-reschedule`, `never`) | `never` |\n| `--pw-device` | Emulate a specific device | `None` |\n| `--pw-debug` | Enable Playwright debug mode by setting `PWDEBUG=1` | `False` |\n| `--pw-open-last-trace` | Open the last captured Playwright trace after the test run | `False` |\n\n### Example Usage\n\n```shell\n$ vedro run --pw-browser=firefox --pw-headed --pw-screenshots=on-failure --save-artifacts\n```\n\n### Capture Modes\n\n`CaptureMode` determines when to capture artifacts:\n\n- `never`: Do not capture.\n- `on-failure`: Capture only when a scenario fails.\n- `on-reschedule`: Capture when a scenario is rescheduled.\n- `always`: Always capture.\n\nArtifacts like screenshots, videos, and traces are attached to the scenario results and can be used in reports.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Integrates Playwright for automated browser testing with customizable configuration options",
"version": "0.3.0",
"project_urls": {
"Docs": "https://github.com/vedro-universe/vedro-pw",
"GitHub": "https://github.com/vedro-universe/vedro-pw",
"Homepage": "https://github.com/vedro-universe/vedro-pw"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "53be3fd26f24a1cc9951c222ec7ae8251945502b3ba6cd5914833cb0acddefa5",
"md5": "8b3041883ca99bfcd115af2c1c5a4bb1",
"sha256": "a1212be8653bda921e46314b29bc58e8c37a4514509595f72c5f768a7fe99e24"
},
"downloads": -1,
"filename": "vedro_pw-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8b3041883ca99bfcd115af2c1c5a4bb1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 24284,
"upload_time": "2025-02-23T10:42:23",
"upload_time_iso_8601": "2025-02-23T10:42:23.152977Z",
"url": "https://files.pythonhosted.org/packages/53/be/3fd26f24a1cc9951c222ec7ae8251945502b3ba6cd5914833cb0acddefa5/vedro_pw-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "064f97c47e9139a4e825d17effd2c8cf59f8c124d05d0ad2d11e63c78b0a2484",
"md5": "7e615fcdc22ebf5558e81e61b07fe5ce",
"sha256": "5d91573b14e6a1d59e57590853cfdd79cabe9cbe5a058a580c5f3ee183208dd5"
},
"downloads": -1,
"filename": "vedro_pw-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "7e615fcdc22ebf5558e81e61b07fe5ce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 22628,
"upload_time": "2025-02-23T10:42:24",
"upload_time_iso_8601": "2025-02-23T10:42:24.097321Z",
"url": "https://files.pythonhosted.org/packages/06/4f/97c47e9139a4e825d17effd2c8cf59f8c124d05d0ad2d11e63c78b0a2484/vedro_pw-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-23 10:42:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vedro-universe",
"github_project": "vedro-pw",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "vedro",
"specs": [
[
">=",
"1.7"
],
[
"<",
"2.0"
]
]
},
{
"name": "playwright",
"specs": [
[
">=",
"1.38"
],
[
"<",
"2.0"
]
]
},
{
"name": "vedro-shared-resource",
"specs": [
[
"<",
"1.0"
],
[
">=",
"0.2"
]
]
}
],
"lcname": "vedro-pw"
}