Skip to content

Commit

Permalink
[java] update names and references or chromium driver service classes
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Dec 10, 2022
1 parent e54fedb commit 3e146d0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
48 changes: 24 additions & 24 deletions java/src/org/openqa/selenium/chrome/ChromeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableMap;
import static org.openqa.selenium.remote.Browser.CHROME;

/**
Expand All @@ -39,14 +41,13 @@
public class ChromeDriverService extends DriverService {

/**
* System property that defines the location of the chromedriver executable that will be used by
* System property that defines the location of the ChromeDriver executable that will be used by
* the {@link #createDefaultService() default service}.
*/
public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";

/**
* System property that defines the location of the log that will be written by
* the {@link #createDefaultService() default service}.
* System property that defines the default location where ChromeDriver output is logged.
*/
public static final String CHROME_DRIVER_LOG_PROPERTY = "webdriver.chrome.logfile";

Expand All @@ -56,41 +57,36 @@ public class ChromeDriverService extends DriverService {
public static final String CHROME_DRIVER_LOG_LEVEL_PROPERTY = "webdriver.chrome.loglevel";

/**
* Boolean system property that defines whether chromedriver should append to existing log file.
* Boolean system property that defines whether ChromeDriver should append to existing log file.
*/
public static final String CHROME_DRIVER_APPEND_LOG_PROPERTY =
"webdriver.chrome.appendLog";
public static final String CHROME_DRIVER_APPEND_LOG_PROPERTY = "webdriver.chrome.appendLog";

/**
* Boolean system property that defines whether the chromedriver executable should be started
* Boolean system property that defines whether the ChromeDriver executable should be started
* with verbose logging.
*/
public static final String CHROME_DRIVER_VERBOSE_LOG_PROPERTY =
"webdriver.chrome.verboseLogging";
public static final String CHROME_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.chrome.verboseLogging";

/**
* Boolean system property that defines whether the chromedriver executable should be started
* Boolean system property that defines whether the ChromeDriver executable should be started
* in silent mode.
*/
public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY =
"webdriver.chrome.silentOutput";
public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY = "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";
public static final String CHROME_DRIVER_WHITELISTED_IPS_PROPERTY = "webdriver.chrome.whitelistedIps";

/**
* System property that defines whether the chromedriver executable should check for build
* version compatibility between chromedriver and the browser.
* 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";
public static final String CHROME_DRIVER_DISABLE_BUILD_CHECK = "webdriver.chrome.disableBuildCheck";

/**
* @param executable The chromedriver executable.
* @param executable The ChromeDriver executable.
* @param port Which port to start the ChromeDriver on.
* @param args The arguments to the launched server.
* @param environment The environment for the launched server.
Expand All @@ -101,11 +97,13 @@ public ChromeDriverService(
int port,
List<String> args,
Map<String, String> environment) throws IOException {
super(executable, port, DEFAULT_TIMEOUT, args, environment);
super(executable, port, DEFAULT_TIMEOUT,
unmodifiableList(new ArrayList<>(args)),
unmodifiableMap(new HashMap<>(environment)));
}

/**
* @param executable The chromedriver executable.
* @param executable The ChromeDriver executable.
* @param port Which port to start the ChromeDriver on.
* @param timeout Timeout waiting for driver server to start.
* @param args The arguments to the launched server.
Expand All @@ -118,12 +116,14 @@ public ChromeDriverService(
Duration timeout,
List<String> args,
Map<String, String> environment) throws IOException {
super(executable, port, timeout, args, environment);
super(executable, port, timeout,
unmodifiableList(new ArrayList<>(args)),
unmodifiableMap(new HashMap<>(environment)));
}

/**
* Configures and returns a new {@link ChromeDriverService} using the default configuration. In
* this configuration, the service will use the chromedriver executable identified by the
* this configuration, the service will use the ChromeDriver executable identified by the
* {@link #CHROME_DRIVER_EXE_PROPERTY} system property. Each service created by this method will
* be configured to use a free port on the current system.
*
Expand All @@ -135,7 +135,7 @@ public static ChromeDriverService createDefaultService() {

/**
* Configures and returns a new {@link ChromeDriverService} using the supplied configuration. In
* this configuration, the service will use the chromedriver executable identified by the
* this configuration, the service will use the ChromeDriver executable identified by the
* {@link #CHROME_DRIVER_EXE_PROPERTY} system property. Each service created by this method will
* be configured to use a free port on the current system.
*
Expand Down
30 changes: 16 additions & 14 deletions java/src/org/openqa/selenium/edge/EdgeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.edge;

import com.google.auto.service.AutoService;
Expand All @@ -35,23 +36,23 @@
import static org.openqa.selenium.remote.Browser.EDGE;

/**
* Manages the life and death of the EdgeDriver (MicrosoftWebDriver or MSEdgeDriver).
* Manages the life and death of the MSEdgeDriver
*/
public class EdgeDriverService extends DriverService {

/**
* System property that defines the location of the EdgeDriver executable that will be used by
* System property that defines the location of the MSEdgeDriver executable that will be used by
* the default service.
*/
public static final String EDGE_DRIVER_EXE_PROPERTY = "webdriver.edge.driver";

/**
* System property that defines the default location where MicrosoftWebDriver output is logged.
* System property that defines the default location where MSEdgeDriver output is logged.
*/
public static final String EDGE_DRIVER_LOG_PROPERTY = "webdriver.edge.logfile";

/**
* System property that defines the log level when MicrosoftWebDriver output is logged.
* System property that defines the log level when MSEdgeDriver output is logged.
*/
public static final String EDGE_DRIVER_LOG_LEVEL_PROPERTY = "webdriver.edge.loglevel";

Expand All @@ -61,7 +62,7 @@ public class EdgeDriverService extends DriverService {
public static final String EDGE_DRIVER_APPEND_LOG_PROPERTY = "webdriver.edge.appendLog";

/**
* Boolean system property that defines whether the MicrosoftWebDriver executable should be started
* Boolean system property that defines whether the MSEdgeDriver executable should be started
* with verbose logging.
*/
public static final String EDGE_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.edge.verboseLogging";
Expand All @@ -85,8 +86,8 @@ public class EdgeDriverService extends DriverService {
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 MSEdgeDriver executable.
* @param port Which port to start the MSEdgeDriver on.
* @param timeout Timeout waiting for driver server to start.
* @param args The arguments to the launched server.
* @param environment The environment for the launched server.
Expand All @@ -112,15 +113,15 @@ public EdgeDriverService(
* @return A new ChromiumEdgeDriverService using the default configuration.
*/
public static EdgeDriverService createDefaultService() {
return new EdgeDriverService.Builder().build();
return new 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, Builder> {

private final boolean disableBuildCheck = Boolean.getBoolean(EDGE_DRIVER_DISABLE_BUILD_CHECK);
private boolean appendLog = Boolean.getBoolean(EDGE_DRIVER_APPEND_LOG_PROPERTY);
Expand Down Expand Up @@ -155,7 +156,7 @@ public int score(Capabilities capabilities) {
* @param appendLog True for appending to log file, false otherwise.
* @return A self reference.
*/
public EdgeDriverService.Builder withAppendLog(boolean appendLog) {
public Builder withAppendLog(boolean appendLog) {
this.appendLog = appendLog;
return this;
}
Expand All @@ -166,7 +167,7 @@ public EdgeDriverService.Builder withAppendLog(boolean appendLog) {
* @param verbose whether verbose output is used
* @return A self reference.
*/
public EdgeDriverService.Builder withVerbose(boolean verbose) {
public Builder withVerbose(boolean verbose) {
if (verbose) {
this.logLevel = "ALL";
}
Expand All @@ -177,7 +178,7 @@ public EdgeDriverService.Builder withVerbose(boolean verbose) {
/**
* Configures the driver server log level.
*/
public EdgeDriverService.Builder withLoglevel(String logLevel) {
public Builder withLoglevel(String logLevel) {
this.verbose = false;
this.silent = false;
this.logLevel = logLevel;
Expand All @@ -190,7 +191,7 @@ public EdgeDriverService.Builder withLoglevel(String logLevel) {
* @param silent whether silent output is used
* @return A self reference.
*/
public EdgeDriverService.Builder withSilent(boolean silent) {
public Builder withSilent(boolean silent) {
if (silent) {
this.logLevel = "OFF";
}
Expand All @@ -205,7 +206,7 @@ public EdgeDriverService.Builder withSilent(boolean silent) {
* @param allowedListIps Comma-separated list of remote IPv4 addresses.
* @return A self reference.
*/
public EdgeDriverService.Builder withAllowedListIps(String allowedListIps) {
public Builder withAllowedListIps(String allowedListIps) {
this.allowedListIps = allowedListIps;
return this;
}
Expand Down Expand Up @@ -236,6 +237,7 @@ protected List<String> createArgs() {
}

List<String> args = new ArrayList<>();

args.add(String.format("--port=%d", getPort()));
if (getLogFile() != null) {
args.add(String.format("--log-path=%s", getLogFile().getAbsolutePath()));
Expand Down

0 comments on commit 3e146d0

Please sign in to comment.