You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -15,12 +15,11 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
15
15
16
16
Headless execution is supported for all the browsers on all platforms.
17
17
18
-
This is a Python 3 version of the [https://github.com/microsoft/playwright](https://github.com/microsoft/playwright) project.
19
-
20
-
## Usage
18
+
## Installation
21
19
22
20
```
23
21
pip install playwright
22
+
python -m playwright install
24
23
```
25
24
26
25
This installs Playwright and browser binaries for Chromium, Firefox and WebKit. Once installed, you can `import` Playwright in a Python script and automate web browser interactions.
@@ -41,6 +40,57 @@ Playwright is built to automate the broad and growing set of web browser capabil
41
40
* Native input events for mouse and keyboard
42
41
* Upload and download files
43
42
43
+
## Usage
44
+
45
+
### Pytest
46
+
47
+
For writing end-to-end tests we recommend to use the official [Pytest plugin](https://github.com/microsoft/playwright-pytest#readme) for Playwright. It contains utilities for running it on multiple browsers, having a new page instance on every test or base-url support via a command-line argument. This will in the end look like that:
48
+
49
+
```py
50
+
deftest_playwright_is_visible_on_google(page):
51
+
page.goto("https://www.google.com")
52
+
page.type("input[name=q]", "Playwright GitHub")
53
+
page.click("input[type=submit]")
54
+
page.waitForSelector("text=microsoft/Playwright")
55
+
```
56
+
57
+
For more information checkout the project on [GitHub](https://github.com/microsoft/playwright-pytest#readme).
58
+
59
+
### Standalone
60
+
61
+
For using Playwright standalone, you can either use the sync version or the async variant (async/await). In most cases the sync variant is the right choice to automate the web browsers e.g. for writing end-to-end tests. Both will get initialized with a context manager.
62
+
63
+
#### Sync variant
64
+
65
+
```py
66
+
from playwright import sync_playwright
67
+
68
+
with sync_playwright() as p:
69
+
for browser_type in [p.chromium, p.firefox, p.webkit]:
0 commit comments