docs: get rid of dollar sign prefix in code snippets (#6494)

This commit is contained in:
Max Schmitt 2021-05-11 20:47:48 +02:00 committed by GitHub
parent 6c821a08b3
commit e0aaef5eab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 184 additions and 184 deletions

View file

@ -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: 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 ```sh js
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
``` ```
## async method: Android.devices ## async method: Android.devices

View file

@ -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: 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 ```sh js
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
``` ```
## async method: Electron.launch ## async method: Electron.launch

View file

@ -22,7 +22,7 @@ on when to opt into stable channels, refer to the [Google Chrome & Microsoft Edg
## Firefox ## Firefox
Playwright's Firefox version matches the recent [Firefox Beta](https://www.mozilla.org/en-US/firefox/channel/desktop/) Playwright's Firefox version matches the recent [Firefox Beta](https://www.mozilla.org/en-US/firefox/channel/desktop/)
build. build.
### Firefox-Stable ### Firefox-Stable
@ -32,15 +32,15 @@ Using `firefox-stable` is a 2-steps process:
1. Installing `firefox-stable` with Playwright CLI. 1. Installing `firefox-stable` with Playwright CLI.
```sh js ```sh js
$ npx playwright install firefox-stable npx playwright install firefox-stable
``` ```
```sh java ```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 ```sh python
$ playwright install firefox-stable playwright install firefox-stable
``` ```
2. Using `firefox-stable` channel when launching browser. 2. Using `firefox-stable` channel when launching browser.

View file

@ -16,21 +16,21 @@ configurations for common CI providers.
in Linux agents. Windows and macOS agents do not require any additional dependencies. in Linux agents. Windows and macOS agents do not require any additional dependencies.
1. **Install Playwright**: 1. **Install Playwright**:
```sh js ```sh js
$ npm ci npm ci
# or # or
$ npm install npm install
``` ```
```sh python ```sh python
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
1. **Run your tests**: 1. **Run your tests**:
```sh js ```sh js
$ npm test npm test
``` ```
```sh python ```sh python
$ pytest pytest
``` ```
## CI configurations ## CI configurations

View file

@ -10,15 +10,15 @@ Playwright comes with the command line tools that run via `npx` or as a part of
## Usage ## Usage
```sh js ```sh js
$ npx playwright --help npx playwright --help
``` ```
```sh java ```sh java
$ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI
``` ```
```sh python ```sh python
$ playwright playwright
``` ```
```json js ```json js
@ -33,15 +33,15 @@ $ playwright
## Generate code ## Generate code
```sh js ```sh js
$ npx playwright codegen wikipedia.org npx playwright codegen wikipedia.org
``` ```
```sh java ```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 ```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. 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. 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 ```sh js
$ npx playwright codegen --save-storage=auth.json npx playwright codegen --save-storage=auth.json
# Perform authentication and exit. # Perform authentication and exit.
# auth.json will contain the storage state. # auth.json will contain the storage state.
``` ```
```sh java ```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. # Perform authentication and exit.
# auth.json will contain the storage state. # auth.json will contain the storage state.
``` ```
```sh python ```sh python
$ playwright codegen --save-storage=auth.json playwright codegen --save-storage=auth.json
# Perform authentication and exit. # Perform authentication and exit.
# auth.json will contain the storage state. # 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. 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 ```sh js
$ npx playwright open --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 npx playwright codegen --load-storage=auth.json my.web.app
# Perform actions in authenticated state. # Perform actions in authenticated state.
``` ```
```sh java ```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="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="codegen --load-storage=auth.json my.web.app"
# Perform authentication and exit. # Perform authentication and exit.
# auth.json will contain the storage state. # auth.json will contain the storage state.
``` ```
```sh python ```sh python
$ playwright open --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 playwright codegen --load-storage=auth.json my.web.app
# Perform actions in authenticated state. # Perform actions in authenticated state.
``` ```
@ -175,32 +175,32 @@ With `open`, you can use Playwright bundled browsers to browse web pages. Playwr
```sh js ```sh js
# Open page in Chromium # Open page in Chromium
$ npx playwright open example.com npx playwright open example.com
``` ```
```sh java ```sh java
# Open page in Chromium # 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 ```sh python
# Open page in Chromium # Open page in Chromium
$ playwright open example.com playwright open example.com
``` ```
```sh js ```sh js
# Open page in WebKit # Open page in WebKit
$ npx playwright wk example.com npx playwright wk example.com
``` ```
```sh java ```sh java
# Open page in WebKit # 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 ```sh python
# Open page in WebKit # Open page in WebKit
$ playwright wk example.com playwright wk example.com
``` ```
### Emulate devices ### Emulate devices
@ -208,48 +208,48 @@ $ playwright wk example.com
```sh js ```sh js
# Emulate iPhone 11. # Emulate iPhone 11.
$ npx playwright open --device="iPhone 11" wikipedia.org npx playwright open --device="iPhone 11" wikipedia.org
``` ```
```sh java ```sh java
# Emulate iPhone 11. # 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 ```sh python
# Emulate iPhone 11. # Emulate iPhone 11.
$ playwright open --device="iPhone 11" wikipedia.org playwright open --device="iPhone 11" wikipedia.org
``` ```
### Emulate color scheme and viewport size ### Emulate color scheme and viewport size
```sh js ```sh js
# Emulate screen size and color scheme. # 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 ```sh java
# Emulate screen size and color scheme. # 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 ```sh python
# Emulate screen size and color scheme. # 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 ### Emulate geolocation, language and timezone
```sh js ```sh js
# Emulate timezone, language & location # Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action # 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 ```sh java
# Emulate timezone, language & location # Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action # 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 ```sh python
# Emulate timezone, language & location # Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action # 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 ## Inspect selectors
@ -299,22 +299,22 @@ Generates selector for the given element.
```sh js ```sh js
# See command help # See command help
$ npx playwright screenshot --help npx playwright screenshot --help
``` ```
```sh java ```sh java
# See command help # 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 ```sh python
# See command help # See command help
$ playwright screenshot --help playwright screenshot --help
``` ```
```sh js ```sh js
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires) # Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
$ npx playwright screenshot \ npx playwright screenshot \
--device="iPhone 11" \ --device="iPhone 11" \
--color-scheme=dark \ --color-scheme=dark \
--wait-for-timeout=3000 \ --wait-for-timeout=3000 \
@ -323,12 +323,12 @@ $ npx playwright screenshot \
```sh java ```sh java
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires) # 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 ```sh python
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires) # Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
$ playwright screenshot \ playwright screenshot \
--device="iPhone 11" \ --device="iPhone 11" \
--color-scheme=dark \ --color-scheme=dark \
--wait-for-timeout=3000 \ --wait-for-timeout=3000 \
@ -337,17 +337,17 @@ $ playwright screenshot \
```sh js ```sh js
# Capture a full page screenshot # 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 ```sh java
# Capture a full page screenshot # 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 ```sh python
# Capture a full page screenshot # 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 ## Generate PDF
@ -356,17 +356,17 @@ PDF generation only works in Headless Chromium.
```sh js ```sh js
# See command help # 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 ```sh java
# See command help # 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 ```sh python
# See command help # 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 ## Install system dependencies
@ -375,17 +375,17 @@ Ubuntu 18.04 and Ubuntu 20.04 system dependencies can get installed automaticall
```sh js ```sh js
# See command help # See command help
$ npx playwright install-deps npx playwright install-deps
``` ```
```sh java ```sh java
# See command help # 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 ```sh python
# See command help # See command help
$ playwright install-deps playwright install-deps
``` ```
## Known limitations ## Known limitations

View file

@ -90,29 +90,29 @@ composite selectors.
```sh js ```sh js
# Linux/macOS # Linux/macOS
$ PWDEBUG=console npm run test PWDEBUG=console npm run test
# Windows # Windows
$ set PWDEBUG=console set PWDEBUG=console
$ npm run test npm run test
``` ```
```sh java ```sh java
# Linux/macOS # Linux/macOS
$ PWDEBUG=console mvn test PWDEBUG=console mvn test
# Windows # Windows
$ set PWDEBUG=console set PWDEBUG=console
$ mvn test mvn test
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ PWDEBUG=console pytest -s PWDEBUG=console pytest -s
# Windows # Windows
$ set PWDEBUG=console set PWDEBUG=console
$ pytest -s pytest -s
``` ```
## Selectors in Developer Tools Console ## Selectors in Developer Tools Console
@ -157,27 +157,27 @@ Playwright supports verbose logging with the `DEBUG` environment variable.
```sh js ```sh js
# Linux/macOS # Linux/macOS
$ DEBUG=pw:api npm run test DEBUG=pw:api npm run test
# Windows # Windows
$ set DEBUG=pw:api set DEBUG=pw:api
$ npm run test npm run test
``` ```
```sh java ```sh java
# Linux/macOS # Linux/macOS
$ DEBUG=pw:api mvn test DEBUG=pw:api mvn test
# Windows # Windows
$ set DEBUG=pw:api set DEBUG=pw:api
$ mvn test mvn test
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ DEBUG=pw:api pytest -s DEBUG=pw:api pytest -s
# Windows # Windows
$ set DEBUG=pw:api set DEBUG=pw:api
$ pytest -s pytest -s
``` ```

View file

@ -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. 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 ```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 ```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: [`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. 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: 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
``` ```

View file

@ -17,30 +17,30 @@ There are several ways of opening Playwright Inspector:
configures Playwright for debugging and opens the inspector. configures Playwright for debugging and opens the inspector.
```sh js ```sh js
# Linux/macOS # Linux/macOS
$ PWDEBUG=1 npm run test PWDEBUG=1 npm run test
# Windows # Windows
$ set PWDEBUG=1 set PWDEBUG=1
$ npm run test npm run test
``` ```
```sh java ```sh java
# Linux/macOS # Linux/macOS
$ PWDEBUG=1 PLAYWRIGHT_JAVA_SRC=<java src root> mvn test PWDEBUG=1 PLAYWRIGHT_JAVA_SRC=<java src root> mvn test
# Windows # Windows
$ set PLAYWRIGHT_JAVA_SRC=<java src root> set PLAYWRIGHT_JAVA_SRC=<java src root>
$ set PWDEBUG=1 set PWDEBUG=1
$ mvn test mvn test
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ PWDEBUG=1 pytest -s PWDEBUG=1 pytest -s
# Windows # Windows
$ set PWDEBUG=1 set PWDEBUG=1
$ pytest -s pytest -s
``` ```
Additional useful defaults are configured when `PWDEBUG=1` is set: 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): - Use `open` or `codegen` commands in the Playwright [CLI](./cli.md):
```sh js ```sh js
$ npx playwright codegen wikipedia.org npx playwright codegen wikipedia.org
``` ```
```sh java ```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 ```sh python
$ playwright codegen wikipedia.org playwright codegen wikipedia.org
``` ```
## Stepping through the Playwright script ## Stepping through the Playwright script

View file

@ -14,18 +14,18 @@ Each version of Playwright needs specific versions of browser binaries to operat
- `~/.cache/ms-playwright` on Linux - `~/.cache/ms-playwright` on Linux
```sh js ```sh js
$ npm i -D playwright npm i -D playwright
``` ```
```sh python ```sh python
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
These browsers will take few hundreds of megabytes of the disk space when installed: These browsers will take few hundreds of megabytes of the disk space when installed:
```sh ```sh
$ du -hs ./Library/Caches/ms-playwright/* du -hs ./Library/Caches/ms-playwright/*
281M chromium-XXXXXX 281M chromium-XXXXXX
187M firefox-XXXX 187M firefox-XXXX
180M webkit-XXXX 180M webkit-XXXX
@ -35,53 +35,53 @@ You can override default behavior using environment variables. When installing P
```sh js ```sh js
# Linux/macOS # Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright
# Windows # Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ npm i -D playwright npm i -D playwright
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ pip install playwright pip install playwright
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
# Windows # Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
```sh java ```sh java
# Linux/macOS # 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. When running Playwright scripts, ask it to search for browsers in a shared location.
```sh js ```sh js
# Linux/macOS # Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js
# Windows # Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ node playwright-script.js node playwright-script.js
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.js PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.js
# Windows # Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ python playwright_script.py python playwright_script.py
``` ```
```sh java ```sh java
# Windows # Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ mvn test mvn test
``` ```
Or you can opt into the hermetic install and place binaries in the local folder: 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 ```sh js
# Linux/macOS # Linux/macOS
# Places binaries to node_modules/playwright # Places binaries to node_modules/playwright
$ PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright
# Windows # Windows
# Places binaries to node_modules\playwright # Places binaries to node_modules\playwright
$ set PLAYWRIGHT_BROWSERS_PATH=0 set PLAYWRIGHT_BROWSERS_PATH=0
$ npm i -D playwright npm i -D playwright
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ pip install playwright pip install playwright
$ PLAYWRIGHT_BROWSERS_PATH=0 playwright install PLAYWRIGHT_BROWSERS_PATH=0 playwright install
# Windows # Windows
$ set PLAYWRIGHT_BROWSERS_PATH=0 set PLAYWRIGHT_BROWSERS_PATH=0
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions. 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 ```sh js
# Linux/macOS # 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 # Windows
$ set HTTPS_PROXY=https://192.168.1.78 set HTTPS_PROXY=https://192.168.1.78
$ npm i -D playwright npm i -D playwright
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ pip install playwright pip install playwright
$ HTTPS_PROXY=https://192.168.1.78 playwright install HTTPS_PROXY=https://192.168.1.78 playwright install
# Windows # Windows
$ set HTTPS_PROXY=https://192.168.1.78 set HTTPS_PROXY=https://192.168.1.78
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
```sh java ```sh java
# Linux/macOS # Linux/macOS
$ HTTPS_PROXY=https://192.168.1.78 mvn test HTTPS_PROXY=https://192.168.1.78 mvn test
# Windows # Windows
$ set HTTPS_PROXY=https://192.168.1.78 set HTTPS_PROXY=https://192.168.1.78
$ mvn test mvn test
``` ```
## Download from artifact repository ## Download from artifact repository
@ -160,31 +160,31 @@ location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable.
```sh js ```sh js
# Linux/macOS # 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 # Windows
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
$ npm i -D playwright npm i -D playwright
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ pip install playwright pip install playwright
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 playwright install PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 playwright install
# Windows # Windows
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
```sh java ```sh java
# Linux/macOS # Linux/macOS
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test
# Windows # Windows
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
$ mvn test 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 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 ```sh js
# Linux/macOS # 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 ```sh python
# Linux/macOS # Linux/macOS
$ pip install playwright pip install playwright
$ PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 python -m playwright install PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 python -m playwright install
``` ```
```sh java ```sh java
# Linux/macOS # 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 ## Skip browser downloads
@ -217,31 +217,31 @@ This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before i
```sh js ```sh js
# Linux/macOS # Linux/macOS
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
# Windows # Windows
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
$ npm i -D playwright npm i -D playwright
``` ```
```sh python ```sh python
# Linux/macOS # Linux/macOS
$ pip install playwright pip install playwright
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install
# Windows # Windows
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
```sh java ```sh java
# Linux/macOS # Linux/macOS
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test
# Windows # Windows
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
$ mvn test mvn test
``` ```
## Download single browser binary ## Download single browser binary
@ -261,7 +261,7 @@ Using these packages is as easy as using a regular Playwright:
Install a specific package Install a specific package
```sh ```sh
$ npm i -D playwright-webkit npm i -D playwright-webkit
``` ```
Require package 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. Playwright downloads Chromium, Firefox and WebKit browsers by default. To install a specific browser, pass it as an argument during installation.
```sh ```sh
$ pip install playwright pip install playwright
$ playwright install firefox playwright install firefox
``` ```
## Stale browser removal ## Stale browser removal

View file

@ -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. Command Line Interface [CLI](./cli.md) can be used to record user interactions and generate Java code.
```sh ```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 ## System requirements

View file

@ -11,7 +11,7 @@ title: "Getting Started"
Use npm or Yarn to install Playwright in your Node.js project. See [system requirements](#system-requirements). Use npm or Yarn to install Playwright in your Node.js project. See [system requirements](#system-requirements).
```sh ```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). 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. Command Line Interface [CLI](./cli.md) can be used to record user interactions and generate JavaScript code.
```sh ```sh
$ npx playwright codegen wikipedia.org npx playwright codegen wikipedia.org
``` ```
## TypeScript support ## TypeScript support

View file

@ -11,8 +11,8 @@ title: "Getting Started"
Use pip to install Playwright in your Python project. See [system requirements](#system-requirements). Use pip to install Playwright in your Python project. See [system requirements](#system-requirements).
```sh ```sh
$ pip install playwright pip install playwright
$ playwright install 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). 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. Command Line Interface [CLI](./cli.md) can be used to record user interactions and generate Python code.
```sh ```sh
$ playwright codegen wikipedia.org playwright codegen wikipedia.org
``` ```
## System requirements ## System requirements

View file

@ -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()`. - [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. - Playwright now includes [command line interface](./cli.md), former playwright-cli.
```sh js ```sh js
$ npx playwright --help npx playwright --help
``` ```
```sh python ```sh python
$ playwright --help playwright --help
``` ```
- [`method: Page.selectOption`] now waits for the options to be present. - [`method: Page.selectOption`] now waits for the options to be present.
- New methods to [assert element state](./actionability#assertions) like [`method: Page.isEditable`]. - New methods to [assert element state](./actionability#assertions) like [`method: Page.isEditable`].

View file

@ -11,7 +11,7 @@ in Python.
## Usage ## Usage
```sh ```sh
$ pip install pytest-playwright pip install pytest-playwright
``` ```
Use the `page` fixture to write a basic test. See [more examples](#examples). 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 ```sh
# Run tests (Chromium and headless by default) # Run tests (Chromium and headless by default)
$ pytest pytest
# Run tests in headed mode # Run tests in headed mode
$ pytest --headed pytest --headed
# Run tests in a different browser (chromium, firefox, webkit) # Run tests in a different browser (chromium, firefox, webkit)
$ pytest --browser firefox pytest --browser firefox
# Run tests in multiple browsers # 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: 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. Start Pytest with the `base-url` argument.
```sh ```sh
$ pytest --base-url http://localhost:8080 pytest --base-url http://localhost:8080
``` ```
```py ```py

View file

@ -38,11 +38,11 @@ Playwright enables fast, reliable and capable automation across all modern brows
## Integrates with your workflow ## Integrates with your workflow
* **One-line installation**. Installing Playwright auto-downloads browser dependencies for your team to be onboarded quickly. * **One-line installation**. Installing Playwright auto-downloads browser dependencies for your team to be onboarded quickly.
```sh js ```sh js
$ npm i playwright npm i playwright
``` ```
```sh python ```sh python
$ pip install playwright pip install playwright
$ playwright install playwright install
``` ```
* **TypeScript support**. Playwright ships with built-in types for auto-completion and other benefits. * **TypeScript support**. Playwright ships with built-in types for auto-completion and other benefits.

View file

@ -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: To build `playwright` package and save result as `./playwright.tgz` file:
```sh ```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: To debug what files are put into the folder, use `--no-cleanup` flag and inspect the package folder:
```sh ```sh
$ ./packages/build_package.js playwright ./playwright.tgz --no-cleanup ./packages/build_package.js playwright ./playwright.tgz --no-cleanup
$ ls ./packages/playwright # inspect the folder ls ./packages/playwright # inspect the folder
``` ```

4
types/types.d.ts vendored
View file

@ -7737,7 +7737,7 @@ export {};
* via setting the following environment variable when installing Playwright: * via setting the following environment variable when installing Playwright:
* *
* ```sh js * ```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: * via setting the following environment variable when installing Playwright:
* *
* ```sh js * ```sh js
* $ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright * PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
* ``` * ```
* *
*/ */

View file

@ -13,7 +13,7 @@ and shared libraries it provides, per distribution.
To generate a map of browser library to package name on Ubuntu:bionic: To generate a map of browser library to package name on Ubuntu:bionic:
```sh ```sh
$ ./run.sh ubuntu:bionic ./run.sh ubuntu:bionic
``` ```
Results will be saved to the `RUN_RESULT`. Results will be saved to the `RUN_RESULT`.