File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
src/org/openqa/selenium/remote
test/org/openqa/selenium/remote Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ public class RemoteWebDriverBuilder {
126126 private URI remoteHost = null ;
127127 private DriverService driverService ;
128128 private Credentials credentials = null ;
129+ private boolean useCustomConfig ;
129130 private Augmenter augmenter = new Augmenter ();
130131
131132 RemoteWebDriverBuilder () {
@@ -273,6 +274,7 @@ public RemoteWebDriverBuilder config(ClientConfig config) {
273274 }
274275
275276 this .clientConfig = config ;
277+ this .useCustomConfig = true ;
276278
277279 return this ;
278280 }
@@ -336,7 +338,13 @@ WebDriver getLocalDriver() {
336338 throw new SessionNotCreatedException ("Unable to find matching driver for capabilities" );
337339 }
338340
339- return first .get ().get ();
341+ WebDriver localDriver = first .get ().get ();
342+
343+ if (localDriver != null && this .useCustomConfig ) {
344+ throw new IllegalArgumentException ("Custom client config is not supported in local drivers" );
345+ }
346+
347+ return localDriver ;
340348 }
341349
342350 /**
Original file line number Diff line number Diff line change 3838import java .io .IOException ;
3939import java .net .URI ;
4040import java .net .URL ;
41+ import java .time .Duration ;
4142import java .util .ArrayList ;
4243import java .util .List ;
4344import java .util .Map ;
@@ -304,6 +305,19 @@ public void shouldSetRemoteHostUriOnClientConfigIfSet() {
304305 assertThat (seen .get ()).isEqualTo (uri );
305306 }
306307
308+ @ Test
309+ public void shouldThrowErrorIfCustomConfigIfSetForLocalDriver () {
310+ ClientConfig config = ClientConfig .defaultConfig ()
311+ .connectionTimeout (Duration .ofMinutes (5 ))
312+ .readTimeout (Duration .ofMinutes (4 ));
313+
314+ RemoteWebDriverBuilder builder = RemoteWebDriver .builder ()
315+ .oneOf (new FirefoxOptions ())
316+ .config (config );
317+
318+ assertThatExceptionOfType (IllegalArgumentException .class ).isThrownBy (builder ::build );
319+ }
320+
307321 @ Test
308322 public void shouldSetSessionIdFromW3CResponse () {
309323 RemoteWebDriver driver = (RemoteWebDriver ) RemoteWebDriver .builder ()
You can’t perform that action at this time.
0 commit comments