Skip to content

Commit 059175e

Browse files
browser: disable extensions option
1 parent 16f530c commit 059175e

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/BrowserConfig.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,21 @@
2727
import static org.testingisdocumenting.webtau.cfg.ConfigValue.declareBoolean;
2828

2929
public class BrowserConfig implements WebTauConfigHandler {
30-
private static final Supplier<Object> NO_DEFAULT = () -> null;
30+
private static final Supplier<Object> NULL_DEFAULT = () -> null;
3131

3232
private static final ConfigValue windowWidth = declare("windowWidth", "browser window width", () -> 1000);
3333
private static final ConfigValue windowHeight = declare("windowHeight", "browser window height", () -> 800);
3434
private static final ConfigValue headless = declareBoolean("headless", "run headless mode");
3535

3636
private static final ConfigValue browser = declare("browser", "browser name: chrome, firefox", () -> "chrome");
3737

38-
private static final ConfigValue chromeBinPath = declare("chromeBinPath", "path to chrome binary", NO_DEFAULT);
39-
private static final ConfigValue chromeDriverPath = declare("chromeDriverPath", "path to chrome driver binary", NO_DEFAULT);
38+
private static final ConfigValue disableExtensions = declare("disableExtensions", "run without extensions", () -> false);
4039

41-
private static final ConfigValue firefoxBinPath = declare("firefoxBinPath", "path to firefox binary", NO_DEFAULT);
42-
private static final ConfigValue firefoxDriverPath = declare("firefoxDriverPath", "path to firefox driver binary", NO_DEFAULT);
40+
private static final ConfigValue chromeBinPath = declare("chromeBinPath", "path to chrome binary", NULL_DEFAULT);
41+
private static final ConfigValue chromeDriverPath = declare("chromeDriverPath", "path to chrome driver binary", NULL_DEFAULT);
42+
43+
private static final ConfigValue firefoxBinPath = declare("firefoxBinPath", "path to firefox binary", NULL_DEFAULT);
44+
private static final ConfigValue firefoxDriverPath = declare("firefoxDriverPath", "path to firefox driver binary", NULL_DEFAULT);
4345

4446
public static String getBrowser() {
4547
return browser.getAsString();
@@ -57,6 +59,10 @@ public static boolean isHeadless() {
5759
return headless.getAsBoolean();
5860
}
5961

62+
public static boolean areExtensionsDisabled() {
63+
return disableExtensions.getAsBoolean();
64+
}
65+
6066
public static void setHeadless(boolean isHeadless) {
6167
headless.set("manual", isHeadless);
6268
}
@@ -84,6 +90,7 @@ public Stream<ConfigValue> additionalConfigValues() {
8490
windowWidth,
8591
windowHeight,
8692
headless,
93+
disableExtensions,
8794
chromeDriverPath,
8895
chromeBinPath,
8996
firefoxDriverPath,

webtau-browser/src/main/java/org/testingisdocumenting/webtau/browser/driver/WebDriverCreator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ private static ChromeDriver createChromeDriver() {
9494
options.addArguments("--disable-gpu");
9595
}
9696

97+
if (BrowserConfig.areExtensionsDisabled()) {
98+
options.addArguments("--disable-extensions");
99+
options.setExperimentalOption("useAutomationExtension", false);
100+
}
101+
97102
if (System.getProperty(CHROME_DRIVER_PATH_KEY) == null) {
98103
setupDriverManagerConfig();
99104
downloadDriverMessage("chrome");

0 commit comments

Comments
 (0)