Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 156 additions & 30 deletions dotnet/docs/browsers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,35 +120,77 @@ du -hs ~/Library/Caches/ms-playwright/*

You can override default behavior using environment variables. When installing Playwright, ask it to download browsers into a specific location:

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers
playwright install
```

# Windows with cmd.exe
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
playwright install
</TabItem>
<TabItem value="powershell">

# Windows with PowerShell
```powershell
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
playwright install
```

</TabItem>
<TabItem value="batch">

```batch
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
playwright install
```

</TabItem>
</Tabs>

When running Playwright scripts, ask it to search for browsers in a shared location.

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers dotnet test
```

# Windows with cmd.exe
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
dotnet test
</TabItem>
<TabItem value="powershell">

# Windows with PowerShell
```powershell
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
dotnet test
```

</TabItem>
<TabItem value="batch">

```batch
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
dotnet test
```

</TabItem>
</Tabs>

Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.

:::note
Expand All @@ -160,60 +202,123 @@ Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME

You can opt into the hermetic install and place binaries in the local folder:

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
# Places binaries to node_modules/@playwright/test
PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install
```

# Windows with cmd.exe
</TabItem>
<TabItem value="powershell">

```powershell
# Places binaries to node_modules\@playwright\test
set PLAYWRIGHT_BROWSERS_PATH=0
$env:PLAYWRIGHT_BROWSERS_PATH=0
npx playwright install
```

# Windows with PowerShell
</TabItem>
<TabItem value="batch">

```batch
# Places binaries to node_modules\@playwright\test
$env:PLAYWRIGHT_BROWSERS_PATH=0
set PLAYWRIGHT_BROWSERS_PATH=0
npx playwright install
```

</TabItem>
</Tabs>

## Install behind a firewall or a proxy

By default, Playwright downloads browsers from Microsoft CDN.

Sometimes companies maintain an internal proxy that blocks direct access to the public resources. In this case, Playwright can be configured to download browsers via a proxy server.

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
HTTPS_PROXY=https://192.0.2.1 playwright install
```

# Windows with cmd.exe
set HTTPS_PROXY=https://192.0.2.1
playwright install
</TabItem>
<TabItem value="powershell">

# Windows with PowerShell
```powershell
$env:HTTPS_PROXY="https://192.0.2.1"
playwright install
```

</TabItem>
<TabItem value="batch">

```batch
set HTTPS_PROXY=https://192.0.2.1
playwright install
```

</TabItem>
</Tabs>

## Download from artifact repository

By default, Playwright downloads browsers from Microsoft CDN.

Sometimes companies maintain an internal artifact repository to host browser binaries. In this case, Playwright can be configured to download from a custom location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable.

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 playwright install
```

# Windows with cmd.exe
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
playwright install
</TabItem>
<TabItem value="powershell">

# Windows with PowerShell
```powershell
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
playwright install
```

</TabItem>
<TabItem value="batch">

```batch
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
playwright install
```

</TabItem>
</Tabs>

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 take precedence over `PLAYWRIGHT_DOWNLOAD_HOST`.

```bash
Expand All @@ -227,19 +332,40 @@ In certain cases, it is desired to avoid browser downloads altogether because br

This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation.

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 playwright install
```

# Windows with cmd.exe
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
playwright install
</TabItem>
<TabItem value="powershell">

# Windows with PowerShell
```powershell
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
playwright install
```

</TabItem>
<TabItem value="batch">

```batch
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
playwright install
```

</TabItem>
</Tabs>

## Stale browser removal

Playwright keeps track of the clients that use its browsers. When there are no more clients that require particular version of the browser, that version is deleted from the system. That way you can safely use Playwright instances of different versions and at the same time, you don't waste disk space for the browsers that are no longer in use.
Expand Down
30 changes: 25 additions & 5 deletions dotnet/docs/debug.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,39 @@ Setup [`launch.json` configuration](https://code.visualstudio.com/docs/nodejs/no

Playwright supports verbose logging with the `DEBUG` environment variable.

<Tabs
groupId="bash-flavor"
defaultValue="bash"
values={[
{label: 'Bash', value: 'bash'},
{label: 'PowerShell', value: 'powershell'},
{label: 'Batch', value: 'batch'}
]
}>
<TabItem value="bash">

```bash
# Linux/macOS
DEBUG=pw:api dotnet run
```

# Windows with cmd.exe
set DEBUG=pw:api
dotnet run
</TabItem>
<TabItem value="powershell">

# Windows with PowerShell
```powershell
$env:DEBUG="pw:api"
dotnet run
```

</TabItem>
<TabItem value="batch">

```batch
set DEBUG=pw:api
dotnet run
```

</TabItem>
</Tabs>

[Accessibility]: ./api/class-accessibility.mdx "Accessibility"
[Browser]: ./api/class-browser.mdx "Browser"
Expand Down
2 changes: 1 addition & 1 deletion dotnet/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
},
prism: {
theme: require('prism-react-renderer/themes/dracula'),
additionalLanguages: ['csharp'],
additionalLanguages: ['csharp', 'bash', 'batch', 'powershell'],
},
navbar: {
title: "Playwright for .NET",
Expand Down
Loading