2020-12-30 18:04:51 -08:00
|
|
|
<!-- THIS FILE IS NOW GENERATED -->
|
|
|
|
|
2020-05-03 14:22:07 -07:00
|
|
|
# Advanced installation
|
2020-04-24 12:20:04 -07:00
|
|
|
|
|
|
|
<!-- GEN:toc -->
|
|
|
|
- [Managing browser binaries](#managing-browser-binaries)
|
2020-04-29 18:59:20 -07:00
|
|
|
- [Download from artifact repository](#download-from-artifact-repository)
|
|
|
|
- [Skip browser downloads](#skip-browser-downloads)
|
2020-04-24 12:20:04 -07:00
|
|
|
- [Download single browser binary](#download-single-browser-binary)
|
|
|
|
<!-- GEN:stop -->
|
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
<br>
|
|
|
|
|
2020-04-24 12:20:04 -07:00
|
|
|
## Managing browser binaries
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
Each version of Playwright needs specific versions of browser binaries to
|
|
|
|
operate. By default Playwright downloads Chromium, WebKit and Firefox browsers
|
|
|
|
into the OS-specific cache folders:
|
2020-04-30 17:41:56 -07:00
|
|
|
- `%USERPROFILE%\AppData\Local\ms-playwright` on Windows
|
2020-04-29 18:59:20 -07:00
|
|
|
- `~/Library/Caches/ms-playwright` on MacOS
|
2020-05-03 16:58:46 +02:00
|
|
|
- `~/.cache/ms-playwright` on Linux
|
2020-04-21 17:13:14 -07:00
|
|
|
|
|
|
|
```sh
|
2020-05-26 10:24:48 -07:00
|
|
|
npm i -D playwright
|
2020-04-21 17:13:14 -07:00
|
|
|
```
|
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
These browsers will take few hundreds of megabytes of the disk space when
|
|
|
|
installed:
|
2020-04-21 17:13:14 -07:00
|
|
|
|
|
|
|
```sh
|
2020-04-29 18:59:20 -07:00
|
|
|
du -hs ./Library/Caches/ms-playwright/*
|
|
|
|
281M chromium-XXXXXX
|
2020-05-07 22:33:35 +03:00
|
|
|
187M firefox-XXXX
|
|
|
|
180M webkit-XXXX
|
2020-04-21 17:13:14 -07:00
|
|
|
```
|
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
You can override default behavior using environment variables. When installing
|
|
|
|
Playwright, ask it to download browsers into a specific location:
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
```sh
|
2020-06-13 13:11:39 -07:00
|
|
|
# Linux/macOS
|
2020-05-26 10:24:48 -07:00
|
|
|
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright
|
2020-06-13 13:11:39 -07:00
|
|
|
|
|
|
|
# Windows
|
|
|
|
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
|
|
|
$ npm i -D playwright
|
2020-04-29 18:59:20 -07:00
|
|
|
```
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
When running Playwright scripts, ask it to search for browsers in a shared
|
|
|
|
location:
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
```sh
|
2020-06-13 13:11:39 -07:00
|
|
|
# Linux/macOS
|
2020-04-29 18:59:20 -07:00
|
|
|
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js
|
2020-06-13 13:11:39 -07:00
|
|
|
|
|
|
|
# Windows
|
|
|
|
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
|
|
|
|
$ node playwright-script.js
|
2020-04-29 18:59:20 -07:00
|
|
|
```
|
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
Or you can opt into the hermetic install and place binaries under the
|
|
|
|
`node_modules/` folder:
|
2020-04-21 16:38:40 -07:00
|
|
|
|
|
|
|
```sh
|
2020-06-13 13:11:39 -07:00
|
|
|
# Linux/macOS
|
|
|
|
$ PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright
|
|
|
|
|
|
|
|
# Windows
|
|
|
|
$ set PLAYWRIGHT_BROWSERS_PATH=0
|
|
|
|
$ npm i -D playwright
|
2020-04-21 16:38:40 -07:00
|
|
|
```
|
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
Playwright keeps track of packages that need those browsers and will garbage
|
|
|
|
collect them as you update Playwright to the newer versions.
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
<br>
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
> **NOTE** Developers can opt-in in this mode via exporting
|
|
|
|
`PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers` in their `.bashrc`.
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
<br>
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
## Download from artifact repository
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
By default, Playwright downloads browsers from Microsoft and Google public CDNs.
|
|
|
|
|
|
|
|
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.
|
2020-04-21 16:38:40 -07:00
|
|
|
|
|
|
|
```sh
|
2020-06-13 13:11:39 -07:00
|
|
|
# Linux/macOS
|
2020-05-26 10:24:48 -07:00
|
|
|
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
|
2020-06-13 13:11:39 -07:00
|
|
|
|
|
|
|
# Windows
|
|
|
|
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
|
|
|
|
$ npm i -D playwright
|
2020-04-21 16:38:40 -07:00
|
|
|
```
|
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
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`.
|
2020-06-18 12:35:37 -07:00
|
|
|
|
|
|
|
```sh
|
|
|
|
# Linux/macOS
|
|
|
|
$ PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=192.168.1.1 PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
|
|
|
|
```
|
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
<br>
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
## Skip browser downloads
|
2020-04-21 16:38:40 -07:00
|
|
|
|
2020-04-24 12:20:04 -07:00
|
|
|
In certain cases, it is desired to avoid browser downloads altogether because
|
2020-04-21 16:38:40 -07:00
|
|
|
browser binaries are managed separately.
|
|
|
|
|
2020-12-30 18:04:51 -08:00
|
|
|
This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before
|
|
|
|
installation.
|
2020-04-21 16:38:40 -07:00
|
|
|
|
|
|
|
```sh
|
2020-06-13 13:11:39 -07:00
|
|
|
# Linux/macOS
|
2020-05-26 10:24:48 -07:00
|
|
|
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
2020-06-13 13:11:39 -07:00
|
|
|
|
|
|
|
# Windows
|
|
|
|
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
|
|
|
$ npm i -D playwright
|
2020-04-21 16:38:40 -07:00
|
|
|
```
|
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
<br>
|
|
|
|
|
2020-04-21 16:38:40 -07:00
|
|
|
## Download single browser binary
|
|
|
|
|
|
|
|
Playwright ships three packages that bundle only a single browser:
|
|
|
|
- [`playwright-chromium`](https://www.npmjs.com/package/playwright-chromium)
|
|
|
|
- [`playwright-webkit`](https://www.npmjs.com/package/playwright-webkit)
|
|
|
|
- [`playwright-firefox`](https://www.npmjs.com/package/playwright-firefox)
|
|
|
|
|
|
|
|
> **NOTE** All configuration environment variables also apply to these packages.
|
|
|
|
|
|
|
|
Using these packages is as easy as using a regular Playwright:
|
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
Install a specific package
|
2020-04-21 16:38:40 -07:00
|
|
|
|
|
|
|
```sh
|
2020-05-26 10:24:48 -07:00
|
|
|
$ npm i -D playwright-webkit
|
2020-04-21 16:38:40 -07:00
|
|
|
```
|
|
|
|
|
2020-04-29 18:59:20 -07:00
|
|
|
Require package
|
2020-04-21 16:38:40 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
// Notice a proper package name in require
|
2020-04-24 12:20:04 -07:00
|
|
|
const { webkit } = require('playwright-webkit');
|
2020-04-21 16:38:40 -07:00
|
|
|
|
|
|
|
(async () => {
|
|
|
|
const browser = await webkit.launch();
|
2020-06-13 13:11:39 -07:00
|
|
|
// ...
|
2020-04-21 16:38:40 -07:00
|
|
|
})();
|
|
|
|
```
|
2020-12-30 18:04:51 -08:00
|
|
|
|
|
|
|
[Playwright]: api.md#class-playwright "Playwright"
|
|
|
|
[Browser]: api.md#class-browser "Browser"
|
|
|
|
[BrowserContext]: api.md#class-browsercontext "BrowserContext"
|
|
|
|
[Page]: api.md#class-page "Page"
|
|
|
|
[Frame]: api.md#class-frame "Frame"
|
|
|
|
[ElementHandle]: api.md#class-elementhandle "ElementHandle"
|
|
|
|
[JSHandle]: api.md#class-jshandle "JSHandle"
|
|
|
|
[ConsoleMessage]: api.md#class-consolemessage "ConsoleMessage"
|
|
|
|
[Dialog]: api.md#class-dialog "Dialog"
|
|
|
|
[Download]: api.md#class-download "Download"
|
|
|
|
[Video]: api.md#class-video "Video"
|
|
|
|
[FileChooser]: api.md#class-filechooser "FileChooser"
|
|
|
|
[Keyboard]: api.md#class-keyboard "Keyboard"
|
|
|
|
[Mouse]: api.md#class-mouse "Mouse"
|
|
|
|
[Touchscreen]: api.md#class-touchscreen "Touchscreen"
|
|
|
|
[Request]: api.md#class-request "Request"
|
|
|
|
[Response]: api.md#class-response "Response"
|
|
|
|
[Selectors]: api.md#class-selectors "Selectors"
|
|
|
|
[Route]: api.md#class-route "Route"
|
|
|
|
[WebSocket]: api.md#class-websocket "WebSocket"
|
|
|
|
[TimeoutError]: api.md#class-timeouterror "TimeoutError"
|
|
|
|
[Accessibility]: api.md#class-accessibility "Accessibility"
|
|
|
|
[Worker]: api.md#class-worker "Worker"
|
|
|
|
[BrowserServer]: api.md#class-browserserver "BrowserServer"
|
|
|
|
[BrowserType]: api.md#class-browsertype "BrowserType"
|
|
|
|
[Logger]: api.md#class-logger "Logger"
|
|
|
|
[ChromiumBrowser]: api.md#class-chromiumbrowser "ChromiumBrowser"
|
|
|
|
[ChromiumBrowserContext]: api.md#class-chromiumbrowsercontext "ChromiumBrowserContext"
|
|
|
|
[ChromiumCoverage]: api.md#class-chromiumcoverage "ChromiumCoverage"
|
|
|
|
[CDPSession]: api.md#class-cdpsession "CDPSession"
|
|
|
|
[FirefoxBrowser]: api.md#class-firefoxbrowser "FirefoxBrowser"
|
|
|
|
[WebKitBrowser]: api.md#class-webkitbrowser "WebKitBrowser"
|
|
|
|
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
|
|
|
|
[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
|
|
|
|
[ChildProcess]: https://nodejs.org/api/child_process.html "ChildProcess"
|
|
|
|
[Element]: https://developer.mozilla.org/en-US/docs/Web/API/element "Element"
|
|
|
|
[Error]: https://nodejs.org/api/errors.html#errors_class_error "Error"
|
|
|
|
[EvaluationArgument]: #evaluationargument "Evaluation Argument"
|
|
|
|
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
|
|
|
|
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object"
|
|
|
|
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
|
|
|
|
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp "RegExp"
|
|
|
|
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
|
|
|
|
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
|
|
|
|
[URL]: https://nodejs.org/api/url.html "URL"
|
|
|
|
[USKeyboardLayout]: ../src/usKeyboardLayout.ts "USKeyboardLayout"
|
|
|
|
[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time"
|
|
|
|
[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
|
|
|
|
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
|
|
|
|
[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols "Iterator"
|
|
|
|
[null]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null"
|
|
|
|
[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number"
|
|
|
|
[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin "Origin"
|
|
|
|
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
|
|
|
|
[Readable]: https://nodejs.org/api/stream.html#stream_class_stream_readable "Readable"
|
|
|
|
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string"
|
|
|
|
[xpath]: https://developer.mozilla.org/en-US/docs/Web/XPath "xpath"
|