Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/test/java/org/openqa/selenium/htmlunit/WebDriverTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
Copy link
Contributor Author

@sbabcoc sbabcoc Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be expressed as HtmlUnitOption.HISTORY_SIZE_LIMIT.getCapabilityKey(), but that's a bit more verbose and doesn't really enhance the readability of the implementation.

We could also incorporate the capability key declarations directly into HtmlUnitDriverOptions by implementing the two "names" interfaces (BrowserVersionTraitNames and HtmlUnitOptionNames), but I think this actually muddles the implied scope of each option.

}

final Integer timeout = getWebClientTimeout();
if (timeout != null) {
options.setTimeout(timeout.intValue());

if (getWebClientTimeout() != null) {
driverOptions.setCapability(HtmlUnitOption.optTimeout, getWebClientTimeout());
Copy link
Contributor Author

@sbabcoc sbabcoc Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be expressed as HtmlUnitOption.TIMEOUT.getCapabilityKey(), with the same verbosity issue. This also adds a pointless method invocation to retrieve a declared constant.

}

final HtmlUnitDriverOptions driverOptions = new HtmlUnitDriverOptions(getBrowserVersion());
driverOptions.importOptions(options);


webDriver_ = new HtmlUnitDriver(driverOptions);
webDriver_.setExecutor(EXECUTOR_POOL);
}
Expand Down