mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-04 16:44:11 +03:00
docs: get rid of dollar sign prefix in code snippets (#6494)
This commit is contained in:
parent
6c821a08b3
commit
e0aaef5eab
@ -63,7 +63,7 @@ const { _android: android } = require('playwright');
|
||||
Note that since you don't need Playwright to install web browsers when testing Android, you can omit browser download via setting the following environment variable when installing Playwright:
|
||||
|
||||
```sh js
|
||||
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
```
|
||||
|
||||
## async method: Android.devices
|
||||
|
@ -42,7 +42,7 @@ const { _electron: electron } = require('playwright');
|
||||
Note that since you don't need Playwright to install web browsers when testing Electron, you can omit browser download via setting the following environment variable when installing Playwright:
|
||||
|
||||
```sh js
|
||||
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
```
|
||||
|
||||
## async method: Electron.launch
|
||||
|
@ -22,7 +22,7 @@ on when to opt into stable channels, refer to the [Google Chrome & Microsoft Edg
|
||||
## Firefox
|
||||
|
||||
Playwright's Firefox version matches the recent [Firefox Beta](https://www.mozilla.org/en-US/firefox/channel/desktop/)
|
||||
build.
|
||||
build.
|
||||
|
||||
### Firefox-Stable
|
||||
|
||||
@ -32,15 +32,15 @@ Using `firefox-stable` is a 2-steps process:
|
||||
|
||||
1. Installing `firefox-stable` with Playwright CLI.
|
||||
```sh js
|
||||
$ npx playwright install firefox-stable
|
||||
npx playwright install firefox-stable
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install firefox-stable"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install firefox-stable"
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ playwright install firefox-stable
|
||||
playwright install firefox-stable
|
||||
```
|
||||
|
||||
2. Using `firefox-stable` channel when launching browser.
|
||||
|
@ -16,21 +16,21 @@ configurations for common CI providers.
|
||||
in Linux agents. Windows and macOS agents do not require any additional dependencies.
|
||||
1. **Install Playwright**:
|
||||
```sh js
|
||||
$ npm ci
|
||||
npm ci
|
||||
# or
|
||||
$ npm install
|
||||
npm install
|
||||
```
|
||||
```sh python
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
1. **Run your tests**:
|
||||
```sh js
|
||||
$ npm test
|
||||
npm test
|
||||
```
|
||||
```sh python
|
||||
$ pytest
|
||||
pytest
|
||||
```
|
||||
|
||||
## CI configurations
|
||||
|
@ -10,15 +10,15 @@ Playwright comes with the command line tools that run via `npx` or as a part of
|
||||
## Usage
|
||||
|
||||
```sh js
|
||||
$ npx playwright --help
|
||||
npx playwright --help
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ playwright
|
||||
playwright
|
||||
```
|
||||
|
||||
```json js
|
||||
@ -33,15 +33,15 @@ $ playwright
|
||||
## Generate code
|
||||
|
||||
```sh js
|
||||
$ npx playwright codegen wikipedia.org
|
||||
npx playwright codegen wikipedia.org
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ playwright codegen wikipedia.org
|
||||
playwright codegen wikipedia.org
|
||||
```
|
||||
|
||||
Run `codegen` and perform actions in the browser. Playwright CLI will generate JavaScript code for the user interactions. `codegen` will attempt to generate resilient text-based selectors.
|
||||
@ -53,19 +53,19 @@ Run `codegen` and perform actions in the browser. Playwright CLI will generate J
|
||||
Run `codegen` with `--save-storage` to save [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) at the end. This is useful to separately record authentication step and reuse it later.
|
||||
|
||||
```sh js
|
||||
$ npx playwright codegen --save-storage=auth.json
|
||||
npx playwright codegen --save-storage=auth.json
|
||||
# Perform authentication and exit.
|
||||
# auth.json will contain the storage state.
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen --save-storage=auth.json"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen --save-storage=auth.json"
|
||||
# Perform authentication and exit.
|
||||
# auth.json will contain the storage state.
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ playwright codegen --save-storage=auth.json
|
||||
playwright codegen --save-storage=auth.json
|
||||
# Perform authentication and exit.
|
||||
# auth.json will contain the storage state.
|
||||
```
|
||||
@ -73,21 +73,21 @@ $ playwright codegen --save-storage=auth.json
|
||||
Run with `--load-storage` to consume previously loaded storage. This way, all [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) will be restored, bringing most web apps to the authenticated state.
|
||||
|
||||
```sh js
|
||||
$ npx playwright open --load-storage=auth.json my.web.app
|
||||
$ npx playwright codegen --load-storage=auth.json my.web.app
|
||||
npx playwright open --load-storage=auth.json my.web.app
|
||||
npx playwright codegen --load-storage=auth.json my.web.app
|
||||
# Perform actions in authenticated state.
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="open --load-storage=auth.json my.web.app"
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen --load-storage=auth.json my.web.app"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="open --load-storage=auth.json my.web.app"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen --load-storage=auth.json my.web.app"
|
||||
# Perform authentication and exit.
|
||||
# auth.json will contain the storage state.
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ playwright open --load-storage=auth.json my.web.app
|
||||
$ playwright codegen --load-storage=auth.json my.web.app
|
||||
playwright open --load-storage=auth.json my.web.app
|
||||
playwright codegen --load-storage=auth.json my.web.app
|
||||
# Perform actions in authenticated state.
|
||||
```
|
||||
|
||||
@ -175,32 +175,32 @@ With `open`, you can use Playwright bundled browsers to browse web pages. Playwr
|
||||
|
||||
```sh js
|
||||
# Open page in Chromium
|
||||
$ npx playwright open example.com
|
||||
npx playwright open example.com
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Open page in Chromium
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="open example.com"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="open example.com"
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Open page in Chromium
|
||||
$ playwright open example.com
|
||||
playwright open example.com
|
||||
```
|
||||
|
||||
```sh js
|
||||
# Open page in WebKit
|
||||
$ npx playwright wk example.com
|
||||
npx playwright wk example.com
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Open page in WebKit
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="wk example.com"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="wk example.com"
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Open page in WebKit
|
||||
$ playwright wk example.com
|
||||
playwright wk example.com
|
||||
```
|
||||
|
||||
### Emulate devices
|
||||
@ -208,48 +208,48 @@ $ playwright wk example.com
|
||||
|
||||
```sh js
|
||||
# Emulate iPhone 11.
|
||||
$ npx playwright open --device="iPhone 11" wikipedia.org
|
||||
npx playwright open --device="iPhone 11" wikipedia.org
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Emulate iPhone 11.
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='open --device="iPhone 11" wikipedia.org'
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='open --device="iPhone 11" wikipedia.org'
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Emulate iPhone 11.
|
||||
$ playwright open --device="iPhone 11" wikipedia.org
|
||||
playwright open --device="iPhone 11" wikipedia.org
|
||||
```
|
||||
|
||||
### Emulate color scheme and viewport size
|
||||
```sh js
|
||||
# Emulate screen size and color scheme.
|
||||
$ npx playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
|
||||
npx playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
|
||||
```
|
||||
```sh java
|
||||
# Emulate screen size and color scheme.
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="open --viewport-size=800,600 --color-scheme=dark twitter.com"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="open --viewport-size=800,600 --color-scheme=dark twitter.com"
|
||||
```
|
||||
```sh python
|
||||
# Emulate screen size and color scheme.
|
||||
$ playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
|
||||
playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
|
||||
```
|
||||
|
||||
### Emulate geolocation, language and timezone
|
||||
```sh js
|
||||
# Emulate timezone, language & location
|
||||
# Once page opens, click the "my location" button to see geolocation in action
|
||||
$ npx playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
|
||||
npx playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
|
||||
```
|
||||
```sh java
|
||||
# Emulate timezone, language & location
|
||||
# Once page opens, click the "my location" button to see geolocation in action
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com'
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com'
|
||||
```
|
||||
```sh python
|
||||
# Emulate timezone, language & location
|
||||
# Once page opens, click the "my location" button to see geolocation in action
|
||||
$ playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
|
||||
playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
|
||||
```
|
||||
|
||||
## Inspect selectors
|
||||
@ -299,22 +299,22 @@ Generates selector for the given element.
|
||||
|
||||
```sh js
|
||||
# See command help
|
||||
$ npx playwright screenshot --help
|
||||
npx playwright screenshot --help
|
||||
```
|
||||
|
||||
```sh java
|
||||
# See command help
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="screenshot --help"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="screenshot --help"
|
||||
```
|
||||
|
||||
```sh python
|
||||
# See command help
|
||||
$ playwright screenshot --help
|
||||
playwright screenshot --help
|
||||
```
|
||||
|
||||
```sh js
|
||||
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
|
||||
$ npx playwright screenshot \
|
||||
npx playwright screenshot \
|
||||
--device="iPhone 11" \
|
||||
--color-scheme=dark \
|
||||
--wait-for-timeout=3000 \
|
||||
@ -323,12 +323,12 @@ $ npx playwright screenshot \
|
||||
|
||||
```sh java
|
||||
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='screenshot --device="iPhone 11" --color-scheme=dark --wait-for-timeout=3000 twitter.com twitter-iphone.png'
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='screenshot --device="iPhone 11" --color-scheme=dark --wait-for-timeout=3000 twitter.com twitter-iphone.png'
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
|
||||
$ playwright screenshot \
|
||||
playwright screenshot \
|
||||
--device="iPhone 11" \
|
||||
--color-scheme=dark \
|
||||
--wait-for-timeout=3000 \
|
||||
@ -337,17 +337,17 @@ $ playwright screenshot \
|
||||
|
||||
```sh js
|
||||
# Capture a full page screenshot
|
||||
$ npx playwright screenshot --full-page en.wikipedia.org wiki-full.png
|
||||
npx playwright screenshot --full-page en.wikipedia.org wiki-full.png
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Capture a full page screenshot
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='screenshot --full-page en.wikipedia.org wiki-full.png'
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args='screenshot --full-page en.wikipedia.org wiki-full.png'
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Capture a full page screenshot
|
||||
$ playwright screenshot --full-page en.wikipedia.org wiki-full.png
|
||||
playwright screenshot --full-page en.wikipedia.org wiki-full.png
|
||||
```
|
||||
|
||||
## Generate PDF
|
||||
@ -356,17 +356,17 @@ PDF generation only works in Headless Chromium.
|
||||
|
||||
```sh js
|
||||
# See command help
|
||||
$ npx playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
|
||||
npx playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
|
||||
```
|
||||
|
||||
```sh java
|
||||
# See command help
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="pdf https://en.wikipedia.org/wiki/PDF wiki.pdf"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="pdf https://en.wikipedia.org/wiki/PDF wiki.pdf"
|
||||
```
|
||||
|
||||
```sh python
|
||||
# See command help
|
||||
$ playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
|
||||
playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
|
||||
```
|
||||
|
||||
## Install system dependencies
|
||||
@ -375,17 +375,17 @@ Ubuntu 18.04 and Ubuntu 20.04 system dependencies can get installed automaticall
|
||||
|
||||
```sh js
|
||||
# See command help
|
||||
$ npx playwright install-deps
|
||||
npx playwright install-deps
|
||||
```
|
||||
|
||||
```sh java
|
||||
# See command help
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install-deps"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install-deps"
|
||||
```
|
||||
|
||||
```sh python
|
||||
# See command help
|
||||
$ playwright install-deps
|
||||
playwright install-deps
|
||||
```
|
||||
|
||||
## Known limitations
|
||||
|
@ -90,29 +90,29 @@ composite selectors.
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PWDEBUG=console npm run test
|
||||
PWDEBUG=console npm run test
|
||||
|
||||
# Windows
|
||||
$ set PWDEBUG=console
|
||||
$ npm run test
|
||||
set PWDEBUG=console
|
||||
npm run test
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ PWDEBUG=console mvn test
|
||||
PWDEBUG=console mvn test
|
||||
|
||||
# Windows
|
||||
$ set PWDEBUG=console
|
||||
$ mvn test
|
||||
set PWDEBUG=console
|
||||
mvn test
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ PWDEBUG=console pytest -s
|
||||
PWDEBUG=console pytest -s
|
||||
|
||||
# Windows
|
||||
$ set PWDEBUG=console
|
||||
$ pytest -s
|
||||
set PWDEBUG=console
|
||||
pytest -s
|
||||
```
|
||||
|
||||
## Selectors in Developer Tools Console
|
||||
@ -157,27 +157,27 @@ Playwright supports verbose logging with the `DEBUG` environment variable.
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ DEBUG=pw:api npm run test
|
||||
DEBUG=pw:api npm run test
|
||||
|
||||
# Windows
|
||||
$ set DEBUG=pw:api
|
||||
$ npm run test
|
||||
set DEBUG=pw:api
|
||||
npm run test
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ DEBUG=pw:api mvn test
|
||||
DEBUG=pw:api mvn test
|
||||
|
||||
# Windows
|
||||
$ set DEBUG=pw:api
|
||||
$ mvn test
|
||||
set DEBUG=pw:api
|
||||
mvn test
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ DEBUG=pw:api pytest -s
|
||||
DEBUG=pw:api pytest -s
|
||||
|
||||
# Windows
|
||||
$ set DEBUG=pw:api
|
||||
$ pytest -s
|
||||
set DEBUG=pw:api
|
||||
pytest -s
|
||||
```
|
||||
|
@ -52,11 +52,11 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:focal /bin/bash
|
||||
On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.
|
||||
|
||||
```sh js python csharp
|
||||
$ docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:focal /bin/bash
|
||||
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:focal /bin/bash
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:focal /bin/bash
|
||||
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:focal /bin/bash
|
||||
```
|
||||
|
||||
[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/master/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
|
||||
@ -124,11 +124,11 @@ Browser builds for Firefox and WebKit are built for the [glibc](https://en.wikip
|
||||
Use [`//utils/docker/build.sh`](https://github.com/microsoft/playwright/blob/master/utils/docker/build.sh) to build the image.
|
||||
|
||||
```
|
||||
$ ./utils/docker/build.sh focal playwright:localbuild-focal
|
||||
./utils/docker/build.sh focal playwright:localbuild-focal
|
||||
```
|
||||
|
||||
The image will be tagged as `playwright:localbuild-focal` and could be run as:
|
||||
|
||||
```
|
||||
$ docker run --rm -it playwright:localbuild /bin/bash
|
||||
docker run --rm -it playwright:localbuild /bin/bash
|
||||
```
|
||||
|
@ -17,30 +17,30 @@ There are several ways of opening Playwright Inspector:
|
||||
configures Playwright for debugging and opens the inspector.
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PWDEBUG=1 npm run test
|
||||
PWDEBUG=1 npm run test
|
||||
|
||||
# Windows
|
||||
$ set PWDEBUG=1
|
||||
$ npm run test
|
||||
set PWDEBUG=1
|
||||
npm run test
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ PWDEBUG=1 PLAYWRIGHT_JAVA_SRC=<java src root> mvn test
|
||||
PWDEBUG=1 PLAYWRIGHT_JAVA_SRC=<java src root> mvn test
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_JAVA_SRC=<java src root>
|
||||
$ set PWDEBUG=1
|
||||
$ mvn test
|
||||
set PLAYWRIGHT_JAVA_SRC=<java src root>
|
||||
set PWDEBUG=1
|
||||
mvn test
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ PWDEBUG=1 pytest -s
|
||||
PWDEBUG=1 pytest -s
|
||||
|
||||
# Windows
|
||||
$ set PWDEBUG=1
|
||||
$ pytest -s
|
||||
set PWDEBUG=1
|
||||
pytest -s
|
||||
```
|
||||
|
||||
Additional useful defaults are configured when `PWDEBUG=1` is set:
|
||||
@ -71,15 +71,15 @@ configures Playwright for debugging and opens the inspector.
|
||||
|
||||
- Use `open` or `codegen` commands in the Playwright [CLI](./cli.md):
|
||||
```sh js
|
||||
$ npx playwright codegen wikipedia.org
|
||||
npx playwright codegen wikipedia.org
|
||||
```
|
||||
|
||||
```sh java
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ playwright codegen wikipedia.org
|
||||
playwright codegen wikipedia.org
|
||||
```
|
||||
|
||||
## Stepping through the Playwright script
|
||||
|
@ -14,18 +14,18 @@ Each version of Playwright needs specific versions of browser binaries to operat
|
||||
- `~/.cache/ms-playwright` on Linux
|
||||
|
||||
```sh js
|
||||
$ npm i -D playwright
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
These browsers will take few hundreds of megabytes of the disk space when installed:
|
||||
|
||||
```sh
|
||||
$ du -hs ./Library/Caches/ms-playwright/*
|
||||
du -hs ./Library/Caches/ms-playwright/*
|
||||
281M chromium-XXXXXX
|
||||
187M firefox-XXXX
|
||||
180M webkit-XXXX
|
||||
@ -35,53 +35,53 @@ You can override default behavior using environment variables. When installing P
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright
|
||||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
$ npm i -D playwright
|
||||
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ pip install playwright
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
|
||||
pip install playwright
|
||||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn test
|
||||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn test
|
||||
```
|
||||
|
||||
When running Playwright scripts, ask it to search for browsers in a shared location.
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js
|
||||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
$ node playwright-script.js
|
||||
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
node playwright-script.js
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.js
|
||||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.js
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
$ python playwright_script.py
|
||||
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
python playwright_script.py
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
$ mvn test
|
||||
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
||||
mvn test
|
||||
```
|
||||
|
||||
Or you can opt into the hermetic install and place binaries in the local folder:
|
||||
@ -89,23 +89,23 @@ Or you can opt into the hermetic install and place binaries in the local folder:
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
# Places binaries to node_modules/playwright
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright
|
||||
PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright
|
||||
|
||||
# Windows
|
||||
# Places binaries to node_modules\playwright
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=0
|
||||
$ npm i -D playwright
|
||||
set PLAYWRIGHT_BROWSERS_PATH=0
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ pip install playwright
|
||||
$ PLAYWRIGHT_BROWSERS_PATH=0 playwright install
|
||||
pip install playwright
|
||||
PLAYWRIGHT_BROWSERS_PATH=0 playwright install
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_BROWSERS_PATH=0
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
set PLAYWRIGHT_BROWSERS_PATH=0
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.
|
||||
@ -123,31 +123,31 @@ resources. In this case, Playwright can be configured to download browsers via a
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ HTTPS_PROXY=https://192.168.1.78 npm i -D playwright
|
||||
HTTPS_PROXY=https://192.168.1.78 npm i -D playwright
|
||||
|
||||
# Windows
|
||||
$ set HTTPS_PROXY=https://192.168.1.78
|
||||
$ npm i -D playwright
|
||||
set HTTPS_PROXY=https://192.168.1.78
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ pip install playwright
|
||||
$ HTTPS_PROXY=https://192.168.1.78 playwright install
|
||||
pip install playwright
|
||||
HTTPS_PROXY=https://192.168.1.78 playwright install
|
||||
|
||||
# Windows
|
||||
$ set HTTPS_PROXY=https://192.168.1.78
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
set HTTPS_PROXY=https://192.168.1.78
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ HTTPS_PROXY=https://192.168.1.78 mvn test
|
||||
HTTPS_PROXY=https://192.168.1.78 mvn test
|
||||
|
||||
# Windows
|
||||
$ set HTTPS_PROXY=https://192.168.1.78
|
||||
$ mvn test
|
||||
set HTTPS_PROXY=https://192.168.1.78
|
||||
mvn test
|
||||
```
|
||||
|
||||
## Download from artifact repository
|
||||
@ -160,31 +160,31 @@ location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable.
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
|
||||
PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
||||
$ npm i -D playwright
|
||||
set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ pip install playwright
|
||||
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 playwright install
|
||||
pip install playwright
|
||||
PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 playwright install
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test
|
||||
PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
||||
$ mvn test
|
||||
set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
||||
mvn test
|
||||
```
|
||||
|
||||
It is also possible to use a per-browser download hosts using `PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST`, `PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST` and `PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST` env variables that
|
||||
@ -194,18 +194,18 @@ It is also possible to use a per-browser download hosts using `PLAYWRIGHT_CHROMI
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
|
||||
PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ pip install playwright
|
||||
$ PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 python -m playwright install
|
||||
pip install playwright
|
||||
PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 python -m playwright install
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test
|
||||
PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test
|
||||
```
|
||||
|
||||
## Skip browser downloads
|
||||
@ -217,31 +217,31 @@ This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before i
|
||||
|
||||
```sh js
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
$ npm i -D playwright
|
||||
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
```sh python
|
||||
# Linux/macOS
|
||||
$ pip install playwright
|
||||
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install
|
||||
pip install playwright
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
```sh java
|
||||
# Linux/macOS
|
||||
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test
|
||||
|
||||
# Windows
|
||||
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
$ mvn test
|
||||
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||
mvn test
|
||||
```
|
||||
|
||||
## Download single browser binary
|
||||
@ -261,7 +261,7 @@ Using these packages is as easy as using a regular Playwright:
|
||||
Install a specific package
|
||||
|
||||
```sh
|
||||
$ npm i -D playwright-webkit
|
||||
npm i -D playwright-webkit
|
||||
```
|
||||
|
||||
Require package
|
||||
@ -282,8 +282,8 @@ const { webkit } = require('playwright-webkit');
|
||||
Playwright downloads Chromium, Firefox and WebKit browsers by default. To install a specific browser, pass it as an argument during installation.
|
||||
|
||||
```sh
|
||||
$ pip install playwright
|
||||
$ playwright install firefox
|
||||
pip install playwright
|
||||
playwright install firefox
|
||||
```
|
||||
|
||||
## Stale browser removal
|
||||
|
@ -120,7 +120,7 @@ playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(false).s
|
||||
Command Line Interface [CLI](./cli.md) can be used to record user interactions and generate Java code.
|
||||
|
||||
```sh
|
||||
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
|
||||
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
|
||||
```
|
||||
|
||||
## System requirements
|
||||
|
@ -11,7 +11,7 @@ title: "Getting Started"
|
||||
Use npm or Yarn to install Playwright in your Node.js project. See [system requirements](#system-requirements).
|
||||
|
||||
```sh
|
||||
$ npm i -D playwright
|
||||
npm i -D playwright
|
||||
```
|
||||
|
||||
This single command downloads the Playwright NPM package and browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](./installation.md).
|
||||
@ -66,7 +66,7 @@ firefox.launch({ headless: false, slowMo: 50 });
|
||||
Command Line Interface [CLI](./cli.md) can be used to record user interactions and generate JavaScript code.
|
||||
|
||||
```sh
|
||||
$ npx playwright codegen wikipedia.org
|
||||
npx playwright codegen wikipedia.org
|
||||
```
|
||||
|
||||
## TypeScript support
|
||||
|
@ -11,8 +11,8 @@ title: "Getting Started"
|
||||
Use pip to install Playwright in your Python project. See [system requirements](#system-requirements).
|
||||
|
||||
```sh
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
These commands download the Playwright package and install browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](./installation.md).
|
||||
@ -75,7 +75,7 @@ firefox.launch(headless=False, slow_mo=50)
|
||||
Command Line Interface [CLI](./cli.md) can be used to record user interactions and generate Python code.
|
||||
|
||||
```sh
|
||||
$ playwright codegen wikipedia.org
|
||||
playwright codegen wikipedia.org
|
||||
```
|
||||
|
||||
## System requirements
|
||||
|
@ -84,10 +84,10 @@ This version of Playwright was also tested against the following stable channels
|
||||
- [Selecting elements based on layout](./selectors.md#selecting-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
|
||||
- Playwright now includes [command line interface](./cli.md), former playwright-cli.
|
||||
```sh js
|
||||
$ npx playwright --help
|
||||
npx playwright --help
|
||||
```
|
||||
```sh python
|
||||
$ playwright --help
|
||||
playwright --help
|
||||
```
|
||||
- [`method: Page.selectOption`] now waits for the options to be present.
|
||||
- New methods to [assert element state](./actionability#assertions) like [`method: Page.isEditable`].
|
||||
|
@ -11,7 +11,7 @@ in Python.
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
$ pip install pytest-playwright
|
||||
pip install pytest-playwright
|
||||
```
|
||||
|
||||
Use the `page` fixture to write a basic test. See [more examples](#examples).
|
||||
@ -27,16 +27,16 @@ To run your tests, use pytest CLI.
|
||||
|
||||
```sh
|
||||
# Run tests (Chromium and headless by default)
|
||||
$ pytest
|
||||
pytest
|
||||
|
||||
# Run tests in headed mode
|
||||
$ pytest --headed
|
||||
pytest --headed
|
||||
|
||||
# Run tests in a different browser (chromium, firefox, webkit)
|
||||
$ pytest --browser firefox
|
||||
pytest --browser firefox
|
||||
|
||||
# Run tests in multiple browsers
|
||||
$ pytest --browser chromium --browser webkit
|
||||
pytest --browser chromium --browser webkit
|
||||
```
|
||||
|
||||
If you want to add the CLI arguments automatically without specifying them, you can use the [pytest.ini](https://docs.pytest.org/en/stable/reference.html#ini-options-ref) file:
|
||||
@ -114,7 +114,7 @@ def test_visit_example(page):
|
||||
Start Pytest with the `base-url` argument.
|
||||
|
||||
```sh
|
||||
$ pytest --base-url http://localhost:8080
|
||||
pytest --base-url http://localhost:8080
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -38,11 +38,11 @@ Playwright enables fast, reliable and capable automation across all modern brows
|
||||
## Integrates with your workflow
|
||||
* **One-line installation**. Installing Playwright auto-downloads browser dependencies for your team to be onboarded quickly.
|
||||
```sh js
|
||||
$ npm i playwright
|
||||
npm i playwright
|
||||
```
|
||||
```sh python
|
||||
$ pip install playwright
|
||||
$ playwright install
|
||||
pip install playwright
|
||||
playwright install
|
||||
```
|
||||
|
||||
* **TypeScript support**. Playwright ships with built-in types for auto-completion and other benefits.
|
||||
|
@ -26,14 +26,14 @@ As of May 20, 2020, [`//packages/build_package.js`](./build_package.js) does the
|
||||
To build `playwright` package and save result as `./playwright.tgz` file:
|
||||
|
||||
```sh
|
||||
$ ./packages/build_package.js playwright ./playwright.tgz
|
||||
./packages/build_package.js playwright ./playwright.tgz
|
||||
```
|
||||
|
||||
To debug what files are put into the folder, use `--no-cleanup` flag and inspect the package folder:
|
||||
|
||||
```sh
|
||||
$ ./packages/build_package.js playwright ./playwright.tgz --no-cleanup
|
||||
$ ls ./packages/playwright # inspect the folder
|
||||
./packages/build_package.js playwright ./playwright.tgz --no-cleanup
|
||||
ls ./packages/playwright # inspect the folder
|
||||
```
|
||||
|
||||
|
||||
|
4
types/types.d.ts
vendored
4
types/types.d.ts
vendored
@ -7737,7 +7737,7 @@ export {};
|
||||
* via setting the following environment variable when installing Playwright:
|
||||
*
|
||||
* ```sh js
|
||||
* $ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
* PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
@ -9367,7 +9367,7 @@ export interface Download {
|
||||
* via setting the following environment variable when installing Playwright:
|
||||
*
|
||||
* ```sh js
|
||||
* $ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
* PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@ and shared libraries it provides, per distribution.
|
||||
To generate a map of browser library to package name on Ubuntu:bionic:
|
||||
|
||||
```sh
|
||||
$ ./run.sh ubuntu:bionic
|
||||
./run.sh ubuntu:bionic
|
||||
```
|
||||
|
||||
Results will be saved to the `RUN_RESULT`.
|
||||
|
Loading…
Reference in New Issue
Block a user