2021-01-01 15:17:27 -08:00
---
id: cli
2021-08-23 20:10:12 -07:00
title: "Command line tools"
2021-01-01 15:17:27 -08:00
---
2020-12-30 18:04:51 -08:00
2021-06-03 08:08:05 -07:00
Playwright comes with the command line tools.
2020-12-30 18:04:51 -08:00
## Usage
2021-06-02 09:23:06 -07:00
```bash js
2021-05-11 20:47:48 +02:00
npx playwright --help
2020-12-30 18:04:51 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-05-11 20:47:48 +02:00
playwright
2021-01-14 18:19:02 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Use the tools.
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 --help
2021-06-03 08:08:05 -07:00
```
2021-01-15 09:12:47 -08:00
```json js
# Running from `package.json` script
2020-12-30 18:04:51 -08:00
{
"scripts": {
"help": "playwright --help"
}
}
```
2021-06-28 18:50:24 -07:00
## Install browsers
2021-07-12 17:56:08 -07:00
Playwright can install supported browsers.
2021-06-28 18:50:24 -07:00
```bash js
# Running without arguments will install default browsers
npx playwright install
```
```bash java
# Running without arguments will install default browsers
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
2021-06-28 18:50:24 -07:00
```
```bash python
# Running without arguments will install default browsers
playwright install
```
```bash csharp
# Running without arguments will install default browsers
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 install
2021-06-28 18:50:24 -07:00
```
You can also install specific browsers by providing an argument:
```bash js
# Install WebKit
npx playwright install webkit
```
```bash java
# Install WebKit
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install webkit"
2021-06-28 18:50:24 -07:00
```
```bash python
# Install WebKit
playwright install webkit
```
```bash csharp
# Install WebKit
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 install webkit
2021-06-28 18:50:24 -07:00
```
See all supported browsers:
```bash js
npx playwright install --help
```
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --help"
2021-06-28 18:50:24 -07:00
```
```bash python
playwright install --help
```
```bash csharp
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 install --help
2021-06-28 18:50:24 -07:00
```
2022-06-08 15:13:33 +02:00
## Install system dependencies
System dependencies can get installed automatically. This is useful for CI environments.
```bash js
# See command help
npx playwright install-deps
```
```bash java
# See command help
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install-deps"
2022-06-08 15:13:33 +02:00
```
```bash python
# See command help
playwright install-deps
```
```bash csharp
# See command help
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 install-deps
2022-06-08 15:13:33 +02:00
```
You can also install the dependencies for a single browser only by passing it as an argument:
```bash js
npx playwright install-deps chromium
```
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install-deps chromium"
2022-06-08 15:13:33 +02:00
```
```bash python
playwright install-deps chromium
```
```bash csharp
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 install-deps chromium
2022-06-08 15:13:33 +02:00
```
It's also possible to combine `install-deps` with `install` and install by that the browsers and OS dependencies with a single command. This would do both for Chromium, but you can also leave it out.
```bash js
npx playwright install --with-deps chromium
```
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps chromium"
2022-06-08 15:13:33 +02:00
```
```bash python
playwright install --with-deps chromium
```
```bash csharp
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 install --with-deps chromium
2022-06-08 15:13:33 +02:00
```
2020-12-30 18:04:51 -08:00
## Generate code
2021-06-02 09:23:06 -07:00
```bash js
2021-05-11 20:47:48 +02:00
npx playwright codegen wikipedia.org
2020-12-30 18:04:51 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen wikipedia.org"
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-05-11 20:47:48 +02:00
playwright codegen wikipedia.org
2021-01-14 18:19:02 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 codegen wikipedia.org
2021-06-03 08:08:05 -07:00
```
2020-12-30 18:04:51 -08:00
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.
2021-01-03 08:47:29 -08:00
< img src = "https://user-images.githubusercontent.com/284612/92536033-7e7ebe00-f1ed-11ea-9e1a-7cbd912e3391.gif" > < / img >
2020-12-30 18:04:51 -08:00
2021-01-05 13:40:42 -08:00
### Preserve authenticated state
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.
2021-06-02 09:23:06 -07:00
```bash js
2021-05-11 20:47:48 +02:00
npx playwright codegen --save-storage=auth.json
2021-01-05 13:40:42 -08:00
# Perform authentication and exit.
# auth.json will contain the storage state.
```
2021-06-02 09:23:06 -07:00
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen --save-storage=auth.json"
2021-03-05 10:13:02 -08:00
# Perform authentication and exit.
# auth.json will contain the storage state.
```
2021-06-02 09:23:06 -07:00
```bash python
2021-05-11 20:47:48 +02:00
playwright codegen --save-storage=auth.json
2021-01-14 18:19:02 -08:00
# Perform authentication and exit.
# auth.json will contain the storage state.
```
2021-06-03 08:08:05 -07:00
```bash csharp
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 codegen --save-storage=auth.json
2021-06-03 08:08:05 -07:00
# Perform authentication and exit.
# auth.json will contain the storage state.
```
2021-01-05 13:40:42 -08:00
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.
2021-06-02 09:23:06 -07:00
```bash js
2021-05-11 20:47:48 +02:00
npx playwright open --load-storage=auth.json my.web.app
npx playwright codegen --load-storage=auth.json my.web.app
2021-01-05 13:40:42 -08:00
# Perform actions in authenticated state.
```
2021-06-02 09:23:06 -07:00
```bash java
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="open --load-storage=auth.json my.web.app"
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen --load-storage=auth.json my.web.app"
2021-03-05 10:13:02 -08:00
# Perform authentication and exit.
# auth.json will contain the storage state.
```
2021-06-02 09:23:06 -07:00
```bash python
2021-05-11 20:47:48 +02:00
playwright open --load-storage=auth.json my.web.app
playwright codegen --load-storage=auth.json my.web.app
2021-01-14 18:19:02 -08:00
# Perform actions in authenticated state.
```
2021-06-03 08:08:05 -07:00
```bash csharp
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 open --load-storage=auth.json my.web.app
pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json my.web.app
2021-06-03 08:08:05 -07:00
# Perform actions in authenticated state.
```
2021-02-06 14:57:01 -08:00
### Codegen with custom setup
If you would like to use codegen in some non-standard setup (for example, use [`method: BrowserContext.route` ]), it is possible to call [`method: Page.pause` ] that will open a separate window with codegen controls.
```js
const { chromium } = require('playwright');
(async () => {
// Make sure to run headed.
const browser = await chromium.launch({ headless: false });
// Setup context however you like.
const context = await browser.newContext({ /* pass any options */ });
await context.route('**/*', route => route.continue());
// Pause the page, and start recording manually.
const page = await context.newPage();
await page.pause();
})();
```
2021-03-01 09:18:44 -08:00
```java
import com.microsoft.playwright.*;
public class Example {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
BrowserType chromium = playwright.chromium();
// Make sure to run headed.
2021-03-05 13:50:34 -08:00
Browser browser = chromium.launch(new BrowserType.LaunchOptions().setHeadless(false));
2021-03-01 09:18:44 -08:00
// Setup context however you like.
BrowserContext context = browser.newContext(/* pass any options */);
context.route("**/*", route -> route.resume());
// Pause the page, and start recording manually.
Page page = context.newPage();
page.pause();
}
}
}
```
2021-02-06 14:57:01 -08:00
```python async
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
# Make sure to run headed.
browser = await p.chromium.launch(headless=False)
# Setup context however you like.
context = await browser.new_context() # Pass any options
await context.route('**/*', lambda route: route.continue_())
# Pause the page, and start recording manually.
page = await context.new_page()
await page.pause()
asyncio.run(main())
```
2021-02-08 12:27:17 -08:00
```python sync
2021-02-06 14:57:01 -08:00
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
# Make sure to run headed.
browser = p.chromium.launch(headless=False)
# Setup context however you like.
context = browser.new_context() # Pass any options
context.route('**/*', lambda route: route.continue_())
# Pause the page, and start recording manually.
page = context.new_page()
page.pause()
```
2021-05-20 08:20:21 -07:00
```csharp
using Microsoft.Playwright;
2022-04-19 21:23:26 +03:00
using var playwright = await Playwright.CreateAsync();
var chromium = playwright.Chromium;
// Make sure to run headed.
var browser = await chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
// Setup context however you like.
var context = await browser.NewContextAsync(); // Pass any options
2022-09-08 21:49:22 +02:00
await context.RouteAsync("**/*", route => route.ContinueAsync());
2022-04-19 21:23:26 +03:00
// Pause the page, and start recording manually.
var page = await context.NewPageAsync();
await page.PauseAsync();
2021-05-20 08:20:21 -07:00
```
2020-12-30 18:04:51 -08:00
## Open pages
With `open` , you can use Playwright bundled browsers to browse web pages. Playwright provides cross-platform WebKit builds that can be used to reproduce Safari rendering across Windows, Linux and macOS.
2021-06-02 09:23:06 -07:00
```bash js
2020-12-30 18:04:51 -08:00
# Open page in Chromium
2021-05-11 20:47:48 +02:00
npx playwright open example.com
2020-12-30 18:04:51 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Open page in Chromium
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="open example.com"
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-01-14 18:19:02 -08:00
# Open page in Chromium
2021-05-11 20:47:48 +02:00
playwright open example.com
2021-01-14 18:19:02 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Open page in Chromium
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 open example.com
2021-06-03 08:08:05 -07:00
```
2021-06-02 09:23:06 -07:00
```bash js
2021-01-14 18:19:02 -08:00
# Open page in WebKit
2021-05-11 20:47:48 +02:00
npx playwright wk example.com
2021-01-14 18:19:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Open page in WebKit
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="wk example.com"
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2020-12-30 18:04:51 -08:00
# Open page in WebKit
2021-05-11 20:47:48 +02:00
playwright wk example.com
2020-12-30 18:04:51 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Open page in WebKit
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 wk example.com
2021-06-03 08:08:05 -07:00
```
2020-12-30 18:04:51 -08:00
### Emulate devices
2021-01-17 12:09:20 -08:00
`open` can emulate mobile and tablet devices from the [`playwright.devices` ](https://playwright.dev/docs/api/class-playwright#playwrightdevices ) list.
2020-12-30 18:04:51 -08:00
2021-06-02 09:23:06 -07:00
```bash js
2020-12-30 18:04:51 -08:00
# Emulate iPhone 11.
2021-05-11 20:47:48 +02:00
npx playwright open --device="iPhone 11" wikipedia.org
2021-01-14 18:19:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Emulate iPhone 11.
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args='open --device="iPhone 11" wikipedia.org'
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-01-14 18:19:02 -08:00
# Emulate iPhone 11.
2021-05-11 20:47:48 +02:00
playwright open --device="iPhone 11" wikipedia.org
2020-12-30 18:04:51 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Emulate iPhone 11.
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 open --device="iPhone 11" wikipedia.org
2021-06-03 08:08:05 -07:00
```
2020-12-30 18:04:51 -08:00
### Emulate color scheme and viewport size
2021-06-03 08:08:05 -07:00
2021-06-02 09:23:06 -07:00
```bash js
2021-01-14 18:19:02 -08:00
# Emulate screen size and color scheme.
2021-05-11 20:47:48 +02:00
npx playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
2021-01-14 18:19:02 -08:00
```
2021-06-03 08:08:05 -07:00
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Emulate screen size and color scheme.
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="open --viewport-size=800,600 --color-scheme=dark twitter.com"
2021-03-05 10:13:02 -08:00
```
2021-06-03 08:08:05 -07:00
2021-06-02 09:23:06 -07:00
```bash python
2020-12-30 18:04:51 -08:00
# Emulate screen size and color scheme.
2021-05-11 20:47:48 +02:00
playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
2020-12-30 18:04:51 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Emulate screen size and color scheme.
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 open --viewport-size=800,600 --color-scheme=dark twitter.com
2021-06-03 08:08:05 -07:00
```
2020-12-30 18:04:51 -08:00
### Emulate geolocation, language and timezone
2021-06-03 08:08:05 -07:00
2021-06-02 09:23:06 -07:00
```bash js
2021-01-14 18:19:02 -08:00
# Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action
2021-05-11 20:47:48 +02:00
npx playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
2021-01-14 18:19:02 -08:00
```
2021-06-03 08:08:05 -07:00
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args='open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com'
2021-03-05 10:13:02 -08:00
```
2021-06-03 08:08:05 -07:00
2021-06-02 09:23:06 -07:00
```bash python
2020-12-30 18:04:51 -08:00
# Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action
2021-05-11 20:47:48 +02:00
playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
2020-12-30 18:04:51 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
2021-06-03 08:08:05 -07:00
```
2020-12-30 18:04:51 -08:00
## Inspect selectors
During `open` or `codegen` , you can use following API inside the developer tools console of any browser.
2021-01-03 08:47:29 -08:00
< img src = "https://user-images.githubusercontent.com/284612/92536317-37dd9380-f1ee-11ea-875d-daf1b206dd56.png" > < / img >
2020-12-30 18:04:51 -08:00
#### playwright.$(selector)
Query Playwright selector, using the actual Playwright query engine, for example:
```js
> playwright.$('.auth-form >> text=Log in');
< button > Log in< / button >
```
#### playwright.$$(selector)
Same as `playwright.$` , but returns all matching elements.
```js
> playwright.$$('li >> text=John')
> [<li>, <li>, <li>, <li>]
```
#### playwright.inspect(selector)
Reveal element in the Elements panel (if DevTools of the respective browser supports it).
```js
> playwright.inspect('text=Log in')
```
2021-12-07 12:32:11 -08:00
#### playwright.locator(selector)
Query Playwright element using the actual Playwright query engine, for example:
```js
2021-12-14 15:37:31 -08:00
> playwright.locator('.auth-form', { hasText: 'Log in' });
2021-12-07 12:32:11 -08:00
> Locator ()
> - element: button
> - elements: [button]
```
2020-12-30 18:04:51 -08:00
#### playwright.selector(element)
Generates selector for the given element.
```js
> playwright.selector($0)
"div[id="glow-ingress-block"] >> text=/.*Hello.*/"
```
## Take screenshot
2021-06-02 09:23:06 -07:00
```bash js
2020-12-30 18:04:51 -08:00
# See command help
2021-05-11 20:47:48 +02:00
npx playwright screenshot --help
2020-12-30 18:04:51 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# See command help
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="screenshot --help"
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-01-14 18:19:02 -08:00
# See command help
2021-05-11 20:47:48 +02:00
playwright screenshot --help
2021-01-14 18:19:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash js
2020-12-30 18:04:51 -08:00
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
2021-05-11 20:47:48 +02:00
npx playwright screenshot \
2021-03-03 22:25:14 -08:00
--device="iPhone 11" \
--color-scheme=dark \
2020-12-30 18:04:51 -08:00
--wait-for-timeout=3000 \
twitter.com twitter-iphone.png
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args='screenshot --device="iPhone 11" --color-scheme=dark --wait-for-timeout=3000 twitter.com twitter-iphone.png'
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-01-14 18:19:02 -08:00
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
2021-05-11 20:47:48 +02:00
playwright screenshot \
2021-03-03 22:25:14 -08:00
--device="iPhone 11" \
--color-scheme=dark \
2021-01-14 18:19:02 -08:00
--wait-for-timeout=3000 \
twitter.com twitter-iphone.png
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 screenshot \
2021-06-03 08:08:05 -07:00
--device="iPhone 11" \
--color-scheme=dark \
--wait-for-timeout=3000 \
twitter.com twitter-iphone.png
```
2021-06-02 09:23:06 -07:00
```bash js
2021-01-14 18:19:02 -08:00
# Capture a full page screenshot
2021-05-11 20:47:48 +02:00
npx playwright screenshot --full-page en.wikipedia.org wiki-full.png
2021-01-14 18:19:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# Capture a full page screenshot
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args='screenshot --full-page en.wikipedia.org wiki-full.png'
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2020-12-30 18:04:51 -08:00
# Capture a full page screenshot
2021-05-11 20:47:48 +02:00
playwright screenshot --full-page en.wikipedia.org wiki-full.png
2020-12-30 18:04:51 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# Capture a full page screenshot
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 screenshot --full-page en.wikipedia.org wiki-full.png
2021-06-03 08:08:05 -07:00
```
2020-12-30 18:04:51 -08:00
## Generate PDF
PDF generation only works in Headless Chromium.
2021-06-02 09:23:06 -07:00
```bash js
2020-12-30 18:04:51 -08:00
# See command help
2021-05-11 20:47:48 +02:00
npx playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
2020-12-30 18:04:51 -08:00
```
2021-06-02 09:23:06 -07:00
```bash java
2021-03-05 10:13:02 -08:00
# See command help
2023-01-05 19:55:07 +01:00
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="pdf https://en.wikipedia.org/wiki/PDF wiki.pdf"
2021-03-05 10:13:02 -08:00
```
2021-06-02 09:23:06 -07:00
```bash python
2021-01-14 18:19:02 -08:00
# See command help
2021-05-11 20:47:48 +02:00
playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
2021-01-14 18:19:02 -08:00
```
2021-06-03 08:08:05 -07:00
```bash csharp
# See command help
2022-08-14 20:01:00 +02:00
pwsh bin/Debug/netX/playwright.ps1 pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
2021-06-03 08:08:05 -07:00
```