From bb243455ec12a003cd4a55c8f21fe4ba9a379620 Mon Sep 17 00:00:00 2001 From: Scott Babcock Date: Sun, 30 Jun 2024 11:43:10 -0700 Subject: [PATCH] Use Capabilities API to set options --- .../selenium/htmlunit/WebDriverTestCase.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/openqa/selenium/htmlunit/WebDriverTestCase.java b/src/test/java/org/openqa/selenium/htmlunit/WebDriverTestCase.java index 626db922..bc79e2b6 100644 --- a/src/test/java/org/openqa/selenium/htmlunit/WebDriverTestCase.java +++ b/src/test/java/org/openqa/selenium/htmlunit/WebDriverTestCase.java @@ -108,6 +108,7 @@ import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.firefox.GeckoDriverService; import org.openqa.selenium.htmlunit.options.HtmlUnitDriverOptions; +import org.openqa.selenium.htmlunit.options.HtmlUnitOption; import org.openqa.selenium.remote.UnreachableBrowserException; /** @@ -541,19 +542,16 @@ protected WebDriver buildWebDriver() throws IOException { throw new RuntimeException("Unexpected BrowserVersion: " + getBrowserVersion()); } if (webDriver_ == null) { - final WebClientOptions options = new WebClientOptions(); + final HtmlUnitDriverOptions driverOptions = new HtmlUnitDriverOptions(getBrowserVersion()); + if (isWebClientCached()) { - options.setHistorySizeLimit(0); + driverOptions.setCapability(HtmlUnitOption.optHistorySizeLimit, 0); } - - final Integer timeout = getWebClientTimeout(); - if (timeout != null) { - options.setTimeout(timeout.intValue()); + + if (getWebClientTimeout() != null) { + driverOptions.setCapability(HtmlUnitOption.optTimeout, getWebClientTimeout()); } - - final HtmlUnitDriverOptions driverOptions = new HtmlUnitDriverOptions(getBrowserVersion()); - driverOptions.importOptions(options); - + webDriver_ = new HtmlUnitDriver(driverOptions); webDriver_.setExecutor(EXECUTOR_POOL); }