From 0cae3bf812f160c61c70104c08e078d5b4f01da2 Mon Sep 17 00:00:00 2001 From: yashp676 Date: Wed, 7 Oct 2026 19:55:58 +0100 Subject: [PATCH 1/2] [java] use reserved hostnames in tests instead of public domains Part of #18093. --- java/test/org/openqa/selenium/PageLoadingTest.java | 4 ++-- .../grid/distributor/DistributorNodeAvailabilityTest.java | 2 +- java/test/org/openqa/selenium/grid/router/EndToEndTest.java | 6 +++--- .../org/openqa/selenium/testing/drivers/GridSupplier.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/java/test/org/openqa/selenium/PageLoadingTest.java b/java/test/org/openqa/selenium/PageLoadingTest.java index e5a792b8dcc87..648804f80ce88 100644 --- a/java/test/org/openqa/selenium/PageLoadingTest.java +++ b/java/test/org/openqa/selenium/PageLoadingTest.java @@ -78,14 +78,14 @@ void testShouldBeAbleToGetAFragmentOnTheCurrentPage() { @NotYetImplemented(EDGE) @NotYetImplemented(FIREFOX) public void testShouldReturnWhenGettingAUrlThatDoesNotResolve() { - assertThatCode(() -> driver.get("http://www.thisurldoesnotexist.comx/")) + assertThatCode(() -> driver.get("http://www.thisurldoesnotexist.invalid/")) .doesNotThrowAnyException(); } @Test void testShouldThrowIfUrlIsMalformed() { assertThatExceptionOfType(WebDriverException.class) - .isThrownBy(() -> driver.get("www.test.com")); + .isThrownBy(() -> driver.get("www.example.test")); } @Test diff --git a/java/test/org/openqa/selenium/grid/distributor/DistributorNodeAvailabilityTest.java b/java/test/org/openqa/selenium/grid/distributor/DistributorNodeAvailabilityTest.java index 54eb595844ea1..be3e7825fbada 100644 --- a/java/test/org/openqa/selenium/grid/distributor/DistributorNodeAvailabilityTest.java +++ b/java/test/org/openqa/selenium/grid/distributor/DistributorNodeAvailabilityTest.java @@ -129,7 +129,7 @@ void shouldBeAbleToRemoveANode() throws MalformedURLException { new RemoteDistributor( tracer, new PassthroughHttpClient.Factory(local), - new URL("http://does.not.exist"), + new URL("http://does.not.exist.invalid"), registrationSecret); distributor.add(node); distributor.remove(node.getId()); diff --git a/java/test/org/openqa/selenium/grid/router/EndToEndTest.java b/java/test/org/openqa/selenium/grid/router/EndToEndTest.java index cb943b0f93b9b..71e0afddf9627 100644 --- a/java/test/org/openqa/selenium/grid/router/EndToEndTest.java +++ b/java/test/org/openqa/selenium/grid/router/EndToEndTest.java @@ -173,7 +173,7 @@ void success(Supplier values) { // The node added only has a single node. Make sure we can start and stop sessions. Capabilities caps = new ImmutableCapabilities("browserName", "cheese", "se:type", "cheddar"); WebDriver driver = new RemoteWebDriver(server.getUrl(), caps); - driver.get("http://www.google.com"); + driver.get("http://www.example.com"); // Kill the session, and wait until the grid says it's ready driver.quit(); @@ -190,7 +190,7 @@ void exerciseDriver(Supplier values) { Capabilities caps = new ImmutableCapabilities("browserName", "cheese", "se:type", "cheddar"); WebDriver driver = new RemoteWebDriver(server.getUrl(), caps); try { - driver.get("https://www.google.com"); + driver.get("https://www.example.com"); // The node is still open. Now try to create a second session. It will be added to the queue. // A retry will be attempted and once request times out, it should fail. @@ -212,7 +212,7 @@ void exerciseDriver(Supplier values) { // And now we can open another browser (because the previous one has been closed). RemoteWebDriver newWebDriver = new RemoteWebDriver(server.getUrl(), caps); try { - newWebDriver.get("https://www.google.com"); + newWebDriver.get("https://www.example.com"); } finally { newWebDriver.quit(); } diff --git a/java/test/org/openqa/selenium/testing/drivers/GridSupplier.java b/java/test/org/openqa/selenium/testing/drivers/GridSupplier.java index d62233647e1e1..f161418b13e32 100644 --- a/java/test/org/openqa/selenium/testing/drivers/GridSupplier.java +++ b/java/test/org/openqa/selenium/testing/drivers/GridSupplier.java @@ -106,6 +106,6 @@ private synchronized void startServers() { public static void main(String[] args) { System.setProperty("selenium.browser.grid", "true"); WebDriver driver = new GridSupplier(new FirefoxOptions()).get(); - driver.get("http://www.google.com"); + driver.get("https://www.example.com"); } } From a09117291ef918417dc509fdb54639967731cadf Mon Sep 17 00:00:00 2001 From: yashp676 Date: Wed, 7 Oct 2026 20:46:13 +0100 Subject: [PATCH 2/2] [java] use reserved hostnames for data-only domains in tests Part of #18093. --- .../grid/node/config/NodeOptionsTest.java | 8 ++++---- .../selenium/grid/node/local/LocalNodeTest.java | 6 +++--- .../openqa/selenium/grid/router/RouterTest.java | 4 ++-- .../selenium/ie/InternetExplorerOptionsTest.java | 2 +- .../net/StubNetworkInterfaceProvider.java | 6 +++--- .../selenium/remote/RemoteWebDriverUnitTest.java | 16 ++++++++-------- .../remote/http/jdk/JdkHttpClientTest.java | 12 ++++++------ .../service/DriverCommandExecutorTest.java | 12 ++++++------ .../decorators/DecoratedNavigationTest.java | 2 +- .../decorators/DecoratedWebDriverTest.java | 4 ++-- .../support/decorators/IntegrationTest.java | 4 ++-- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java b/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java index 8bb231aa8ec48..4230e5a1da99b 100644 --- a/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java +++ b/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java @@ -491,7 +491,7 @@ void driversCanBeConfiguredWithASpecificArguments() { String chromeDriverLocation = "/path/to/chromedriver_beta/chromedriver"; ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary(chLocation); - chromeOptions.addArguments("--homepage=https://www.selenium.dev"); + chromeOptions.addArguments("--homepage=https://www.example.test"); StringBuilder chromeCaps = new StringBuilder(); new Json().newOutput(chromeCaps).setPrettyPrint(false).write(chromeOptions); @@ -525,7 +525,7 @@ void driversCanBeConfiguredWithASpecificArguments() { .asInstanceOf(MAP) .extractingByKey("args") .asInstanceOf(LIST) - .containsAnyOf("--homepage=https://www.selenium.dev"); + .containsAnyOf("--homepage=https://www.example.test"); } @Test @@ -647,12 +647,12 @@ void canOverrideMaxSessionsWithFlag() { void settingTheHubFlagSetsTheGridUrlAndEventBusFlags() { String[] rawConfig = new String[] { - "[node]", "hub = \"cheese.com\"", + "[node]", "hub = \"cheese.test\"", }; Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig))); NodeOptions nodeOptions = new NodeOptions(config); - assertThat(nodeOptions.getPublicGridUri()).contains(create("http://cheese.com:4444")); + assertThat(nodeOptions.getPublicGridUri()).contains(create("http://cheese.test:4444")); } @Test diff --git a/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java b/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java index 26b0f534597ff..34725126406ef 100644 --- a/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java +++ b/java/test/org/openqa/selenium/grid/node/local/LocalNodeTest.java @@ -316,7 +316,7 @@ void seVncCdpUrlCapabilityWhenGridUrlWithSubPath() throws URISyntaxException { void seVncCdpUrlCapabilityWhenGridUrlWithTrailingSlash() throws URISyntaxException { Tracer tracer = DefaultTestTracer.createTracer(); EventBus bus = new GuavaEventBus(); - URI uri = new URI("https://my.domain.com/"); + URI uri = new URI("https://my.domain.test/"); Capabilities stereotype = new ImmutableCapabilities( "se:vncLocalAddress", "ws://localhost:7900", @@ -339,11 +339,11 @@ void seVncCdpUrlCapabilityWhenGridUrlWithTrailingSlash() throws URISyntaxExcepti Capabilities capabilities = sessionResponse.getSession().getCapabilities(); Object seVnc = capabilities.getCapability("se:vnc"); assertThat(seVnc).isNotNull(); - assertThat(seVnc.toString().contains("wss://my.domain.com/session")).isTrue(); + assertThat(seVnc.toString().contains("wss://my.domain.test/session")).isTrue(); Object seCdp = capabilities.getCapability("se:cdp"); assertThat(seCdp).isNotNull(); - assertThat(seCdp.toString().contains("wss://my.domain.com/session")).isTrue(); + assertThat(seCdp.toString().contains("wss://my.domain.test/session")).isTrue(); } @Test diff --git a/java/test/org/openqa/selenium/grid/router/RouterTest.java b/java/test/org/openqa/selenium/grid/router/RouterTest.java index 2ddc9a8d56699..29716a0d71224 100644 --- a/java/test/org/openqa/selenium/grid/router/RouterTest.java +++ b/java/test/org/openqa/selenium/grid/router/RouterTest.java @@ -185,8 +185,8 @@ void aNodeThatIsUpAndHasSpareSessionsMeansTheGridIsReady() throws URISyntaxExcep void shouldListAllNodesTheDistributorIsAwareOf() throws URISyntaxException { Capabilities chromeCapabilities = new ImmutableCapabilities("browser", "chrome"); Capabilities firefoxCapabilities = new ImmutableCapabilities("browser", "firefox"); - URI firstNodeUri = new URI("https://example1.com"); - URI secondNodeUri = new URI("https://example2.com"); + URI firstNodeUri = new URI("https://node1.example.test"); + URI secondNodeUri = new URI("https://node2.example.test"); AtomicReference isUp = new AtomicReference<>(UP); diff --git a/java/test/org/openqa/selenium/ie/InternetExplorerOptionsTest.java b/java/test/org/openqa/selenium/ie/InternetExplorerOptionsTest.java index 7443e4e910711..29b8379dfbc33 100644 --- a/java/test/org/openqa/selenium/ie/InternetExplorerOptionsTest.java +++ b/java/test/org/openqa/selenium/ie/InternetExplorerOptionsTest.java @@ -87,7 +87,7 @@ void shouldPopulateIeOptionsFromExistingCapabilitiesWhichLackThem() { void shouldSurviveASerializationRoundTrip() { InternetExplorerOptions options = new InternetExplorerOptions() - .withInitialBrowserUrl("http://www.cheese.com") + .withInitialBrowserUrl("http://www.cheese.test") .addCommandSwitches("--cake"); String json = new Json().toJson(options); diff --git a/java/test/org/openqa/selenium/net/StubNetworkInterfaceProvider.java b/java/test/org/openqa/selenium/net/StubNetworkInterfaceProvider.java index 1ec958ec85a36..5f3409d3d91e9 100644 --- a/java/test/org/openqa/selenium/net/StubNetworkInterfaceProvider.java +++ b/java/test/org/openqa/selenium/net/StubNetworkInterfaceProvider.java @@ -94,7 +94,7 @@ public static NetworkInterfaceProvider getWindowsXpWithIp4Only() { public Iterable getNetworkInterfaces() { return List.of( newInterface("lo", inetAddress("localXhost", "127.0.0.4")), - newInterface("eth0", inetAddress("myip4.mydomain.com", "169.254.8.182"))); + newInterface("eth0", inetAddress("myip4.mydomain.test", "169.254.8.182"))); } @Override @@ -180,12 +180,12 @@ public Iterable getNetworkInterfaces() { newInterface("vmnet1", inetAddress("192.168.166.1")), newInterface( "en1", - inetAddress("somehost.subd.test.com", "172.12.8.7"), + inetAddress("somehost.subd.example.test", "172.12.8.7"), inetAddress("2620:0:1042:13:3bb0:35fe:fe7c:629c"), inetAddress("fe80:0:0:0:3bb0:35fe:fe7c:629c%6")), newInterface( "en0", - inetAddress("someotherhost.subd.test.com", "172.12.8.9"), + inetAddress("someotherhost.subd.example.test", "172.12.8.9"), inetAddress("fe80:0:0:0:6e6d:63ff:fe8c:bd10%4")), newInterface( "lo0", diff --git a/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java b/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java index 7b845796a1e7a..516a82e5d6b88 100644 --- a/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java +++ b/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java @@ -102,18 +102,18 @@ void doesNotAdvertiseRemoteUrlForLocalSession() { void canHandleGetCommand() { WebDriverFixture fixture = new WebDriverFixture(echoCapabilities, nullValueResponder); - fixture.driver.get("http://some.host.com"); + fixture.driver.get("http://some.host.test"); fixture.verifyCommands( - new CommandPayload(DriverCommand.GET, Map.of("url", "http://some.host.com"))); + new CommandPayload(DriverCommand.GET, Map.of("url", "http://some.host.test"))); } @Test void canHandleGetCurrentUrlCommand() { WebDriverFixture fixture = - new WebDriverFixture(echoCapabilities, valueResponder("http://some.host.com")); + new WebDriverFixture(echoCapabilities, valueResponder("http://some.host.test")); - assertThat(fixture.driver.getCurrentUrl()).isEqualTo("http://some.host.com"); + assertThat(fixture.driver.getCurrentUrl()).isEqualTo("http://some.host.test"); fixture.verifyCommands(new CommandPayload(DriverCommand.GET_CURRENT_URL, emptyMap())); } @@ -477,10 +477,10 @@ void canHandleForwardCommand() { void canHandleNavigateToCommand() throws IOException { WebDriverFixture fixture = new WebDriverFixture(echoCapabilities, nullValueResponder); - fixture.driver.navigate().to(new URL("http://www.test.com/")); + fixture.driver.navigate().to(new URL("http://www.example.test/")); fixture.verifyCommands( - new CommandPayload(DriverCommand.GET, Map.of("url", "http://www.test.com/"))); + new CommandPayload(DriverCommand.GET, Map.of("url", "http://www.example.test/"))); } @Test @@ -725,7 +725,7 @@ void canHandleGeneralExceptionThrownByCommandExecutor() { void canHandleGeneralExceptionInNonDebugModeThrownByCommandExecutor() { try (MockedStatic debugMock = Mockito.mockStatic(Debug.class)) { final Map parameters = - sequencedMapOf("url", "https://user:password@somedomain.com", "token", "12345Secret"); + sequencedMapOf("url", "https://user:password@somedomain.test", "token", "12345Secret"); final CommandPayload commandPayload = new CommandPayload(DriverCommand.GET, parameters); debugMock.when(Debug::isDebugging).thenReturn(false); WebDriverFixture fixture = @@ -751,7 +751,7 @@ void canHandleGeneralExceptionInNonDebugModeThrownByCommandExecutor() { void canHandleGeneralExceptionInDebugModeThrownByCommandExecutor() { try (MockedStatic debugMock = Mockito.mockStatic(Debug.class)) { final Map parameters = - Map.of("url", "https://user:password@somedomain.com", "token", "12345Secret"); + Map.of("url", "https://user:password@somedomain.test", "token", "12345Secret"); final CommandPayload commandPayload = new CommandPayload(DriverCommand.GET, parameters); debugMock.when(Debug::isDebugging).thenReturn(true); WebDriverFixture fixture = diff --git a/java/test/org/openqa/selenium/remote/http/jdk/JdkHttpClientTest.java b/java/test/org/openqa/selenium/remote/http/jdk/JdkHttpClientTest.java index 9c85840c167f3..679073147db88 100644 --- a/java/test/org/openqa/selenium/remote/http/jdk/JdkHttpClientTest.java +++ b/java/test/org/openqa/selenium/remote/http/jdk/JdkHttpClientTest.java @@ -33,12 +33,12 @@ protected HttpClient.Factory createFactory() { @Test void maskUrlCredentials_hidesUserInfoInUrl() { - assertThat(maskUrlCredentials("http://user:pass@my.grid.com:4444/wd/hub")) - .isEqualTo("http://***@my.grid.com:4444/wd/hub"); - assertThat(maskUrlCredentials("https://vi:se@myshop.com/wd/hub?email=foo@bar.ee")) - .isEqualTo("https://***@myshop.com/wd/hub?email=foo@bar.ee"); - assertThat(maskUrlCredentials("https://0:@myshop.com/wd/hub")) - .isEqualTo("https://***@myshop.com/wd/hub"); + assertThat(maskUrlCredentials("http://user:pass@my.grid.test:4444/wd/hub")) + .isEqualTo("http://***@my.grid.test:4444/wd/hub"); + assertThat(maskUrlCredentials("https://vi:se@myshop.test/wd/hub?email=foo@bar.test")) + .isEqualTo("https://***@myshop.test/wd/hub?email=foo@bar.test"); + assertThat(maskUrlCredentials("https://0:@myshop.test/wd/hub")) + .isEqualTo("https://***@myshop.test/wd/hub"); } @Test diff --git a/java/test/org/openqa/selenium/remote/service/DriverCommandExecutorTest.java b/java/test/org/openqa/selenium/remote/service/DriverCommandExecutorTest.java index 79b6b5bd9074a..1096694cfbbfc 100644 --- a/java/test/org/openqa/selenium/remote/service/DriverCommandExecutorTest.java +++ b/java/test/org/openqa/selenium/remote/service/DriverCommandExecutorTest.java @@ -43,7 +43,7 @@ @Tag("UnitTests") class DriverCommandExecutorTest { - private static final String DRIVER_SERVER_URL = "http://a.base.url:3000"; + private static final String DRIVER_SERVER_URL = "http://a.base.test:3000"; @Test void shouldStartDriverServerOnTheNewSession() throws IOException { @@ -67,7 +67,7 @@ void shouldNotStartDriverServerOnGetCommand() throws IOException { new Command(new SessionId("some id"), DriverCommand.GET("https://example.com")); Response response = new Response(); DriverService service = mock(DriverService.class); - when(service.getUrl()).thenReturn(new URL("http://a.base.url:3000")); + when(service.getUrl()).thenReturn(new URL("http://a.base.test:3000")); DriverCommandExecutor executor = spy(new DriverCommandExecutor(service)); doReturn(response).when(executor).invokeExecute(any(Command.class)); @@ -82,7 +82,7 @@ void shouldNotStartDriverServerOnGetCommand() throws IOException { void shouldStopDriverServerOnExceptionForTheNewSessionCommand() throws IOException { Command command = new Command(null, DriverCommand.NEW_SESSION(new ImmutableCapabilities())); DriverService service = mock(DriverService.class); - when(service.getUrl()).thenReturn(new URL("http://a.base.url:3000")); + when(service.getUrl()).thenReturn(new URL("http://a.base.test:3000")); when(service.isRunning()).thenReturn(false, true); DriverCommandExecutor executor = spy(new DriverCommandExecutor(service)); @@ -98,7 +98,7 @@ void shouldNotStopDriverServerOnExceptionForGetCommand() throws IOException { Command command = new Command(new SessionId("some id"), DriverCommand.GET("https://example.com")); DriverService service = mock(DriverService.class); - when(service.getUrl()).thenReturn(new URL("http://a.base.url:3000")); + when(service.getUrl()).thenReturn(new URL("http://a.base.test:3000")); DriverCommandExecutor executor = spy(new DriverCommandExecutor(service)); doThrow(WebDriverException.class).when(executor).invokeExecute(any(Command.class)); @@ -114,7 +114,7 @@ void shouldNotStopDriverServerOnExceptionForTheNewSessionCommandIfItWasAlreadyRu throws IOException { Command command = new Command(null, DriverCommand.NEW_SESSION(new ImmutableCapabilities())); DriverService service = mock(DriverService.class); - when(service.getUrl()).thenReturn(new URL("http://a.base.url:3000")); + when(service.getUrl()).thenReturn(new URL("http://a.base.test:3000")); when(service.isRunning()).thenReturn(true); DriverCommandExecutor executor = spy(new DriverCommandExecutor(service)); @@ -129,7 +129,7 @@ void shouldNotStopDriverServerOnExceptionForTheNewSessionCommandIfItWasAlreadyRu void shouldNotStopDriverServerOnExceptionForTheNewSessionCommandIfItDied() throws IOException { Command command = new Command(null, DriverCommand.NEW_SESSION(new ImmutableCapabilities())); DriverService service = mock(DriverService.class); - when(service.getUrl()).thenReturn(new URL("http://a.base.url:3000")); + when(service.getUrl()).thenReturn(new URL("http://a.base.test:3000")); when(service.isRunning()).thenReturn(false); DriverCommandExecutor executor = spy(new DriverCommandExecutor(service)); diff --git a/java/test/org/openqa/selenium/support/decorators/DecoratedNavigationTest.java b/java/test/org/openqa/selenium/support/decorators/DecoratedNavigationTest.java index d78fb17c9bae0..0ca3f26a902c9 100644 --- a/java/test/org/openqa/selenium/support/decorators/DecoratedNavigationTest.java +++ b/java/test/org/openqa/selenium/support/decorators/DecoratedNavigationTest.java @@ -63,7 +63,7 @@ void toAddressAsString() { @Test void toAddressAsUrl() throws MalformedURLException { - final URL url = new URL("http://www.selenium2.ru/"); + final URL url = new URL("http://www.selenium2.test/"); verifyFunction($ -> $.to(url)); } diff --git a/java/test/org/openqa/selenium/support/decorators/DecoratedWebDriverTest.java b/java/test/org/openqa/selenium/support/decorators/DecoratedWebDriverTest.java index c9eea696f89a4..d4372fdda5c91 100644 --- a/java/test/org/openqa/selenium/support/decorators/DecoratedWebDriverTest.java +++ b/java/test/org/openqa/selenium/support/decorators/DecoratedWebDriverTest.java @@ -139,12 +139,12 @@ private void verifyDecoratingFunction(Function f, R result, Co @Test void get() { - verifyFunction(d -> d.get("http://selenium.dev/")); + verifyFunction(d -> d.get("http://example.test/")); } @Test void getCurrentUrl() { - verifyFunction(WebDriver::getCurrentUrl, "http://selenium2.ru/"); + verifyFunction(WebDriver::getCurrentUrl, "http://selenium2.test/"); } @Test diff --git a/java/test/org/openqa/selenium/support/decorators/IntegrationTest.java b/java/test/org/openqa/selenium/support/decorators/IntegrationTest.java index 26e59301b3232..83225a15b9806 100644 --- a/java/test/org/openqa/selenium/support/decorators/IntegrationTest.java +++ b/java/test/org/openqa/selenium/support/decorators/IntegrationTest.java @@ -63,8 +63,8 @@ void canDecorateWebDriverMethods() { CountCalls decorator = new CountCalls(); WebDriver originalDriver = mock(WebDriver.class); WebDriver decoratedDriver = decorator.decorate(originalDriver); - decoratedDriver.get("http://test.com/"); - verify(originalDriver).get("http://test.com/"); + decoratedDriver.get("http://example.test/"); + verify(originalDriver).get("http://example.test/"); assertThat(decorator.counterBefore).isEqualTo(1); assertThat(decorator.counterAfter).isEqualTo(1); }