Skip to content

Commit 32e764d

Browse files
committed
Implementing ability to pass whitelisted-ips option to the chromedriver
1 parent 01bf9a0 commit 32e764d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

java/client/src/org/openqa/selenium/chrome/ChromeDriverService.java

+22
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ public class ChromeDriverService extends DriverService {
5757
public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY =
5858
"webdriver.chrome.silentOutput";
5959

60+
/**
61+
* System property that defines comma-separated list of remote IPv4 addresses which are
62+
* allowed to connect to ChromeDriver.
63+
*/
64+
public final static String CHROME_DRIVER_WHITELISTED_IPS_PROPERTY = "webdriver.chrome.whitelistedIps";
65+
6066
/**
6167
*
6268
* @param executable The chromedriver executable.
@@ -90,6 +96,7 @@ public static class Builder extends DriverService.Builder<
9096

9197
private boolean verbose = Boolean.getBoolean(CHROME_DRIVER_VERBOSE_LOG_PROPERTY);
9298
private boolean silent = Boolean.getBoolean(CHROME_DRIVER_SILENT_OUTPUT_PROPERTY);
99+
private String whitelistedIps = System.getProperty(CHROME_DRIVER_WHITELISTED_IPS_PROPERTY);
93100

94101
/**
95102
* Configures the driver server verbosity.
@@ -113,6 +120,18 @@ public Builder withSilent(boolean silent) {
113120
return this;
114121
}
115122

123+
/**
124+
* Configures the comma-separated list of remote IPv4 addresses which are allowed to connect
125+
* to the driver server.
126+
*
127+
* @param whitelistedIps comma-separated list of remote IPv4 addresses
128+
* @return A self reference.
129+
*/
130+
public Builder withWhitelistedIps(String whitelistedIps) {
131+
this.whitelistedIps = whitelistedIps;
132+
return this;
133+
}
134+
116135
@Override
117136
protected File findDefaultExecutable() {
118137
return findExecutable("chromedriver", CHROME_DRIVER_EXE_PROPERTY,
@@ -140,6 +159,9 @@ protected ImmutableList<String> createArgs() {
140159
if (silent) {
141160
argsBuilder.add("--silent");
142161
}
162+
if (whitelistedIps != null) {
163+
argsBuilder.add(String.format("--whitelisted-ips=%s", whitelistedIps));
164+
}
143165

144166
return argsBuilder.build();
145167
}

0 commit comments

Comments
 (0)