Skip to content

Commit

Permalink
[grid] Adding disableBuildCheck as a property.
Browse files Browse the repository at this point in the history
This allows users to skip version compatibility
check between the driver and the browser, which
is very useful when testing beta and dev versions.
  • Loading branch information
diemol committed Aug 23, 2021
1 parent 86f65a7 commit ea41b75
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 34 deletions.
40 changes: 27 additions & 13 deletions java/src/org/openqa/selenium/chrome/ChromeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@
import static java.util.Collections.unmodifiableList;

import com.google.auto.service.AutoService;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.service.DriverService;

import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.service.DriverService;

/**
* Manages the life and death of a ChromeDriver server.
Expand Down Expand Up @@ -66,14 +68,22 @@ public class ChromeDriverService extends DriverService {
* in silent mode.
*/
public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY =
"webdriver.chrome.silentOutput";
"webdriver.chrome.silentOutput";

/**
* System property that defines comma-separated list of remote IPv4 addresses which are
* allowed to connect to ChromeDriver.
*/
public static final String CHROME_DRIVER_WHITELISTED_IPS_PROPERTY =
"webdriver.chrome.whitelistedIps";
"webdriver.chrome.whitelistedIps";

/**
* System property that defines whether the chromedriver executable should check for build
* version compatibility between chromedriver and the browser.
*/
public static final String
CHROME_DRIVER_DISABLE_BUILD_CHECK =
"webdriver.chrome.disableBuildCheck";

/**
* @param executable The chromedriver executable.
Expand All @@ -83,10 +93,10 @@ public class ChromeDriverService extends DriverService {
* @throws IOException If an I/O error occurs.
*/
public ChromeDriverService(
File executable,
int port,
List<String> args,
Map<String, String> environment) throws IOException {
File executable,
int port,
List<String> args,
Map<String, String> environment) throws IOException {
super(executable, port, DEFAULT_TIMEOUT, args, environment);
}

Expand Down Expand Up @@ -144,6 +154,7 @@ public static class Builder extends DriverService.Builder<
private boolean verbose = Boolean.getBoolean(CHROME_DRIVER_VERBOSE_LOG_PROPERTY);
private boolean silent = Boolean.getBoolean(CHROME_DRIVER_SILENT_OUTPUT_PROPERTY);
private String whitelistedIps = System.getProperty(CHROME_DRIVER_WHITELISTED_IPS_PROPERTY);
private boolean disableBuildCheck = Boolean.getBoolean(CHROME_DRIVER_DISABLE_BUILD_CHECK);
private ChromeDriverLogLevel logLevel = null;

@Override
Expand Down Expand Up @@ -220,9 +231,9 @@ public Builder withWhitelistedIps(String whitelistedIps) {
@Override
protected File findDefaultExecutable() {
return findExecutable(
"chromedriver", CHROME_DRIVER_EXE_PROPERTY,
"https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver",
"http://chromedriver.storage.googleapis.com/index.html");
"chromedriver", CHROME_DRIVER_EXE_PROPERTY,
"https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver",
"https://chromedriver.storage.googleapis.com/index.html");
}

@Override
Expand Down Expand Up @@ -260,6 +271,9 @@ protected List<String> createArgs() {
if (whitelistedIps != null) {
args.add(String.format("--whitelisted-ips=%s", whitelistedIps));
}
if (disableBuildCheck) {
args.add("--disable-build-check");
}

return unmodifiableList(args);
}
Expand Down
52 changes: 31 additions & 21 deletions java/src/org/openqa/selenium/edge/EdgeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,46 +70,53 @@ public class EdgeDriverService extends DriverService {
public static final String EDGE_DRIVER_ALLOWED_IPS_PROPERTY = "webdriver.edge.withAllowedIps";

/**
* Configures and returns a new {@link EdgeDriverService} using the default configuration. In
* this configuration, the service will use the MSEdgeDriver executable identified by the
* {@link #EDGE_DRIVER_EXE_PROPERTY} system property. Each service created by this method will
* be configured to use a free port on the current system.
*
* @return A new ChromiumEdgeDriverService using the default configuration.
* System property that defines whether the MSEdgeDriver executable should check for build
* version compatibility between MSEdgeDriver and the browser.
*/
public static EdgeDriverService createDefaultService() {
return new EdgeDriverService.Builder().build();
}
public static final String EDGE_DRIVER_DISABLE_BUILD_CHECK = "webdriver.edge.disableBuildCheck";

/**
* @param executable The EdgeDriver executable.
* @param port Which port to start the EdgeDriver on.
* @param executable The EdgeDriver executable.
* @param port Which port to start the EdgeDriver on.
* @param timeout Timeout waiting for driver server to start.
* @param args The arguments to the launched server.
* @param args The arguments to the launched server.
* @param environment The environment for the launched server.
* @throws IOException If an I/O error occurs.
*/
public EdgeDriverService(
File executable,
int port,
Duration timeout,
List<String> args,
Map<String, String> environment) throws IOException {
File executable,
int port,
Duration timeout,
List<String> args,
Map<String, String> environment) throws IOException {
super(executable, port, timeout,
unmodifiableList(new ArrayList<>(args)),
unmodifiableMap(new HashMap<>(environment)));
}

/**
* Configures and returns a new {@link EdgeDriverService} using the default configuration. In
* this configuration, the service will use the MSEdgeDriver executable identified by the
* {@link #EDGE_DRIVER_EXE_PROPERTY} system property. Each service created by this method will
* be configured to use a free port on the current system.
*
* @return A new ChromiumEdgeDriverService using the default configuration.
*/
public static EdgeDriverService createDefaultService() {
return new EdgeDriverService.Builder().build();
}

/**
* Builder used to configure new {@link EdgeDriverService} instances.
*/
@AutoService(DriverService.Builder.class)
public static class Builder extends DriverService.Builder<
EdgeDriverService, EdgeDriverService.Builder> {
EdgeDriverService, EdgeDriverService.Builder> {

private boolean verbose = Boolean.getBoolean(EDGE_DRIVER_VERBOSE_LOG_PROPERTY);
private boolean silent = Boolean.getBoolean(EDGE_DRIVER_SILENT_OUTPUT_PROPERTY);
private String allowedListIps = System.getProperty(EDGE_DRIVER_ALLOWED_IPS_PROPERTY);
private boolean disableBuildCheck = Boolean.getBoolean(EDGE_DRIVER_DISABLE_BUILD_CHECK);

@Override
public int score(Capabilities capabilities) {
Expand Down Expand Up @@ -168,9 +175,9 @@ public EdgeDriverService.Builder withAllowedListIps(String allowedListIps) {
@Override
protected File findDefaultExecutable() {
return findExecutable(
"msedgedriver", EDGE_DRIVER_EXE_PROPERTY,
"https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver",
"https://msedgecdn.azurewebsites.net/webdriver/index.html");
"msedgedriver", EDGE_DRIVER_EXE_PROPERTY,
"https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/",
"https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/");
}

@Override
Expand All @@ -196,6 +203,9 @@ protected List<String> createArgs() {
if (allowedListIps != null) {
args.add(String.format("--whitelisted-ips=%s", allowedListIps));
}
if (disableBuildCheck) {
args.add("--disable-build-check");
}

return unmodifiableList(args);
}
Expand Down

0 comments on commit ea41b75

Please sign in to comment.