From 528d01b07a8b00d3ecbaf4a819fab14f59d526da Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 11 Aug 2021 15:38:20 -0700 Subject: [PATCH] fix: do not download browsers if PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 (#551) --- .../java/com/microsoft/playwright/impl/DriverJar.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/driver-bundle/src/main/java/com/microsoft/playwright/impl/DriverJar.java b/driver-bundle/src/main/java/com/microsoft/playwright/impl/DriverJar.java index 7e2f8b82..f5300399 100644 --- a/driver-bundle/src/main/java/com/microsoft/playwright/impl/DriverJar.java +++ b/driver-bundle/src/main/java/com/microsoft/playwright/impl/DriverJar.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; public class DriverJar extends Driver { + private static final String PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD"; private final Path driverTempDir; DriverJar() throws IOException, URISyntaxException, InterruptedException { @@ -39,6 +40,13 @@ public class DriverJar extends Driver { } private void installBrowsers(Map env) throws IOException, InterruptedException { + String skip = env.get(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD); + if (skip == null) { + skip = System.getenv(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD); + } + if (skip != null && !"0".equals(skip) && !"false".equals(skip)) { + return; + } String cliFileName = super.cliFileName(); Path driver = driverTempDir.resolve(cliFileName); if (!Files.exists(driver)) {