From ea41b757bde0b9b42459832134ed6cb77967d3ca Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 23 Aug 2021 13:28:50 +0200 Subject: [PATCH] [grid] Adding `disableBuildCheck` as a property. This allows users to skip version compatibility check between the driver and the browser, which is very useful when testing beta and dev versions. --- .../selenium/chrome/ChromeDriverService.java | 40 +++++++++----- .../selenium/edge/EdgeDriverService.java | 52 +++++++++++-------- 2 files changed, 58 insertions(+), 34 deletions(-) diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java index f927bd310cc19..7c6a27cdafe0d 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java @@ -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. @@ -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. @@ -83,10 +93,10 @@ public class ChromeDriverService extends DriverService { * @throws IOException If an I/O error occurs. */ public ChromeDriverService( - File executable, - int port, - List args, - Map environment) throws IOException { + File executable, + int port, + List args, + Map environment) throws IOException { super(executable, port, DEFAULT_TIMEOUT, args, environment); } @@ -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 @@ -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 @@ -260,6 +271,9 @@ protected List createArgs() { if (whitelistedIps != null) { args.add(String.format("--whitelisted-ips=%s", whitelistedIps)); } + if (disableBuildCheck) { + args.add("--disable-build-check"); + } return unmodifiableList(args); } diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index 24945e2af62a5..157a0ffaaed4d 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -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 args, - Map environment) throws IOException { + File executable, + int port, + Duration timeout, + List args, + Map 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) { @@ -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 @@ -196,6 +203,9 @@ protected List createArgs() { if (allowedListIps != null) { args.add(String.format("--whitelisted-ips=%s", allowedListIps)); } + if (disableBuildCheck) { + args.add("--disable-build-check"); + } return unmodifiableList(args); }