You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+33-18Lines changed: 33 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
🎭 playwright-extra-install-arguments
2
2
===
3
3
4
-
[](https://central.sonatype.com/artifact/com.aldaviva/playwright-extra-install-arguments)
4
+
[](https://central.sonatype.com/artifact/com.aldaviva.playwright/playwright-extra-install-arguments)
5
5
6
6
*Pass extra custom arguments to Playwright's `cli.js` install command, which lets you install one specific browser instead of all supported browsers.*
7
7
@@ -18,19 +18,19 @@
18
18
<!-- /MarkdownTOC -->
19
19
20
20
## Problem
21
-
Unfortunately, the [Java implementation of Playwright](https://playwright.dev/java/docs/intro) has a limitation in its API that prevents you from choosing which browser you want to download. Every time the Playwright is constructed, it will install the latest versions of all available browsers and their dependencies, which can take a lot of time, bandwidth, and disk space (**926 MB** on 2025-04-20). This is especially important in environments with constrained resources, like virtual machines, containers, Function-as-a-Service executions, or any machines with slow or expensive network connections, slow or small storage, or small transfer quotas.
21
+
Unfortunately, the [Java implementation of Playwright](https://playwright.dev/java/docs/intro) has a limitation in its API that prevents you from choosing which browser you want to download. Every time Playwright is constructed, it will install the latest versions of all available browsers and their dependencies, which can take a lot of time, bandwidth, and disk space (**926 MB** on 2025-04-20). This is especially harmful in environments with constrained resources, like virtual machines, containers, Function-as-a-Service executions, or any machines with slow or expensive network connections, slow or small storage, or small transfer quotas.
22
22
23
23
The Node.js API does let you [specify exactly which browsers you want to download](https://playwright.dev/docs/browsers#install-browsers) by passing their names to the `install` command:
24
24
```sh
25
25
node cli.js install chromium
26
26
```
27
27
28
-
Unfortunately, despite bundling and calling the Node.js library internally, the Java API does not expose this functionality, and always insists on calling `node cli.js install` without any browser names. This leads to all browers always being installed.
28
+
Sadly, despite bundling and calling the Node.js library internally, the Java API does not in turn expose this functionality to its own consumers, and always insists on calling `node cli.js install` without any browser names. This leads to all browers always being installed. You may have heard of this phenomenon being referred to as an "API cliff."
29
29
30
-
This issue [has been raised](https://github.com/microsoft/playwright-java/issues/215) to the Playwright maintainers [multiple times](https://github.com/microsoft/playwright-java/issues/388), but they close it each time and offer an insufficient workaround:
31
-
1.install Maven (a development tool) on your production deployment machine
32
-
1.manually fork a new process `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install chromium"`, along with all of the associated process management boilerplate and pitfalls
33
-
1.call`Driver.ensureDriverInstalled(env, false)` before calling `PlaywrightImpl.create(CreateOptions)`
30
+
This issue [has been raised](https://github.com/microsoft/playwright-java/issues/215) to the Playwright maintainers [multiple times](https://github.com/microsoft/playwright-java/issues/388), but they close it as won't-fix each time and offer an insufficient workaround:
31
+
1.Install Maven (a development tool) on your production deployment machine.
32
+
1.Manually fork a new process `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install chromium"`, along with the necessity to deal with all of the associated process and file management boilerplate and pitfalls. How do you know what directory to call that in? What if your application is packaged inside a WAR or EAR?
33
+
1.Call`Driver.ensureDriverInstalled(env, false)` before calling `PlaywrightImpl.create(CreateOptions)`.
34
34
35
35
## Solution
36
36
This library offers an alternative which can easily install only your desired browsers, without forking any processes or manual installations.
@@ -46,7 +46,7 @@ Add a dependency on `com.aldaviva:playwright-extra-install-arguments` to your Ma
-`ExtraInstallArgumentsDriver.activate()` must be called once before any calls to `PlaywrightImpl.create(CreateOptions)`, so that Playwright will use `ExtraInstallArgumentsDriver` instead of the default `DriverJar`.
85
-
- Multiple extra arguments can be separated by a space, comma, or vertical pipe.
86
-
- If you already have an existing `CreateOptions` instance you want to continue using, you may also manually set the extra arguments string as the `PLAYWRIGHT_EXTRA_INSTALL_ARGUMENTS` environment variable (whose name is exposed as the `ExtraInstallArgumentsDriver.EXTRA_INSTALL_ARGUMENTS` constant).
- manually set the extra arguments string as the `PLAYWRIGHT_EXTRA_INSTALL_ARGUMENTS` environment variable (whose name is exposed as the `ExtraInstallArgumentsDriver.EXTRA_INSTALL_ARGUMENTS` constant).
<description>Pass extra custom arguments to Playwright's cli.js install command, which lets you install one specific browser instead of all supported browsers.</description>
* <li>Set the {@code playwright.driver.impl} environment variable to {@code com.aldaviva.playwright.ExtraInstallArgumentsDriver} (using {@link System#setProperty(String, String)}).</li></ul>
22
22
*
23
-
* <li>Specify the extra arguments you want to pass to {@code node cli.js install} by doing one of the following. Multiple arguments are delimited by spaces, commas, or vertical pipes.
23
+
* <li>Specify the extra arguments you want to pass to {@code node cli.js install} by doing one of the following. Multiple arguments are delimited by spaces.
0 commit comments