Skip to content

Commit 45b62fc

Browse files
committed
[java] add tests for adding configs to local driver builder should throw exception
1 parent e3257d6 commit 45b62fc

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.openqa.selenium.chromium.HasCdp;
2727
import org.openqa.selenium.chromium.HasNetworkConditions;
2828
import org.openqa.selenium.chromium.HasPermissions;
29+
import org.openqa.selenium.remote.RemoteWebDriverBuilder;
30+
import org.openqa.selenium.remote.http.ClientConfig;
2931
import org.openqa.selenium.testing.Ignore;
3032
import org.openqa.selenium.testing.JUnit4TestBase;
3133
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
@@ -35,6 +37,7 @@
3537
import java.util.Map;
3638

3739
import static org.assertj.core.api.Assertions.assertThat;
40+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3841
import static org.assertj.core.api.Assertions.fail;
3942
import static org.assertj.core.api.Assumptions.assumeThat;
4043

@@ -59,6 +62,16 @@ public void builderOverridesDefaultChromeOptions() {
5962
driver.quit();
6063
}
6164

65+
@Test
66+
public void builderWithClientConfigthrowsException() {
67+
ClientConfig clientConfig = ClientConfig.defaultConfig().readTimeout(Duration.ofMinutes(1));
68+
RemoteWebDriverBuilder builder = ChromeDriver.builder().config(clientConfig);
69+
70+
assertThatExceptionOfType(IllegalArgumentException.class)
71+
.isThrownBy(builder::build)
72+
.withMessage("ClientConfig instances do not work for Local Drivers");
73+
}
74+
6275
@Test
6376
public void canSetPermission() {
6477
HasPermissions permissions = (HasPermissions) driver;

java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.openqa.selenium.chromium.HasCdp;
2727
import org.openqa.selenium.chromium.HasNetworkConditions;
2828
import org.openqa.selenium.chromium.HasPermissions;
29+
import org.openqa.selenium.remote.RemoteWebDriverBuilder;
30+
import org.openqa.selenium.remote.http.ClientConfig;
2931
import org.openqa.selenium.testing.JUnit4TestBase;
3032
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
3133

@@ -34,6 +36,7 @@
3436
import java.util.Map;
3537

3638
import static org.assertj.core.api.Assertions.assertThat;
39+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3740
import static org.assertj.core.api.Assertions.fail;
3841
import static org.assertj.core.api.Assumptions.assumeThat;
3942

@@ -58,6 +61,16 @@ public void builderOverridesDefaultChromeOptions() {
5861
driver.quit();
5962
}
6063

64+
@Test
65+
public void builderWithClientConfigthrowsException() {
66+
ClientConfig clientConfig = ClientConfig.defaultConfig().readTimeout(Duration.ofMinutes(1));
67+
RemoteWebDriverBuilder builder = EdgeDriver.builder().config(clientConfig);
68+
69+
assertThatExceptionOfType(IllegalArgumentException.class)
70+
.isThrownBy(builder::build)
71+
.withMessage("ClientConfig instances do not work for Local Drivers");
72+
}
73+
6174
@Test
6275
public void canSetPermission() {
6376
HasPermissions permissions = (HasPermissions) driver;

java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
import org.openqa.selenium.remote.CommandExecutor;
4040
import org.openqa.selenium.remote.DriverCommand;
4141
import org.openqa.selenium.remote.RemoteWebDriver;
42+
import org.openqa.selenium.remote.RemoteWebDriverBuilder;
4243
import org.openqa.selenium.remote.SessionId;
4344
import org.openqa.selenium.remote.UnreachableBrowserException;
45+
import org.openqa.selenium.remote.http.ClientConfig;
4446
import org.openqa.selenium.support.ui.ExpectedCondition;
4547
import org.openqa.selenium.support.ui.WebDriverWait;
4648
import org.openqa.selenium.testing.Ignore;
@@ -60,6 +62,7 @@
6062
import java.util.Random;
6163

6264
import static org.assertj.core.api.Assertions.assertThat;
65+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6366
import static org.junit.Assert.fail;
6467
import static org.junit.Assume.assumeNotNull;
6568
import static org.mockito.Mockito.atLeastOnce;
@@ -112,6 +115,16 @@ public void builderOverridesDefaultChromeOptions() {
112115
driver.quit();
113116
}
114117

118+
@Test
119+
public void builderWithClientConfigthrowsException() {
120+
ClientConfig clientConfig = ClientConfig.defaultConfig().readTimeout(Duration.ofMinutes(1));
121+
RemoteWebDriverBuilder builder = FirefoxDriver.builder().config(clientConfig);
122+
123+
assertThatExceptionOfType(IllegalArgumentException.class)
124+
.isThrownBy(builder::build)
125+
.withMessage("ClientConfig instances do not work for Local Drivers");
126+
}
127+
115128
@Test
116129
public void canStartDriverWithNoParameters() {
117130
localDriver = new WebDriverBuilder().get();

java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.openqa.selenium.WebDriver;
2525
import org.openqa.selenium.WebElement;
2626
import org.openqa.selenium.interactions.Actions;
27+
import org.openqa.selenium.remote.RemoteWebDriverBuilder;
28+
import org.openqa.selenium.remote.http.ClientConfig;
2729
import org.openqa.selenium.testing.JUnit4TestBase;
2830
import org.openqa.selenium.testing.NoDriverAfterTest;
2931
import org.openqa.selenium.testing.NoDriverBeforeTest;
@@ -33,6 +35,7 @@
3335
import java.time.Duration;
3436

3537
import static org.assertj.core.api.Assertions.assertThat;
38+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3639
import static org.openqa.selenium.ie.InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING;
3740

3841
public class InternetExplorerDriverTest extends JUnit4TestBase {
@@ -53,6 +56,16 @@ public void builderOverridesDefaultChromeOptions() {
5356
driver.quit();
5457
}
5558

59+
@Test
60+
public void builderWithClientConfigthrowsException() {
61+
ClientConfig clientConfig = ClientConfig.defaultConfig().readTimeout(Duration.ofMinutes(1));
62+
RemoteWebDriverBuilder builder = InternetExplorerDriver.builder().config(clientConfig);
63+
64+
assertThatExceptionOfType(IllegalArgumentException.class)
65+
.isThrownBy(builder::build)
66+
.withMessage("ClientConfig instances do not work for Local Drivers");
67+
}
68+
5669
@Test
5770
@NoDriverBeforeTest
5871
public void canRestartTheIeDriverInATightLoop() {

java/test/org/openqa/selenium/safari/SafariDriverTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.junit.Test;
2222
import org.openqa.selenium.WebDriver;
2323
import org.openqa.selenium.net.PortProber;
24+
import org.openqa.selenium.remote.RemoteWebDriverBuilder;
25+
import org.openqa.selenium.remote.http.ClientConfig;
2426
import org.openqa.selenium.testing.JUnit4TestBase;
2527
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
2628

@@ -31,6 +33,7 @@
3133
import java.time.Duration;
3234

3335
import static org.assertj.core.api.Assertions.assertThat;
36+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3437
import static org.junit.Assume.assumeTrue;
3538

3639
public class SafariDriverTest extends JUnit4TestBase {
@@ -70,6 +73,16 @@ public void builderOverridesDefaultChromeOptions() {
7073
driver.quit();
7174
}
7275

76+
@Test
77+
public void builderWithClientConfigthrowsException() {
78+
ClientConfig clientConfig = ClientConfig.defaultConfig().readTimeout(Duration.ofMinutes(1));
79+
RemoteWebDriverBuilder builder = SafariDriver.builder().config(clientConfig);
80+
81+
assertThatExceptionOfType(IllegalArgumentException.class)
82+
.isThrownBy(builder::build)
83+
.withMessage("ClientConfig instances do not work for Local Drivers");
84+
}
85+
7386
@Test
7487
public void canStartADriverUsingAService() throws IOException {
7588
removeDriver();

0 commit comments

Comments
 (0)