Skip to content

Commit 8012af9

Browse files
committed
[grid] Using getReportedUri instead of parsing moz:debuggerAddress manually
Fixes #9327
1 parent d9c0dd8 commit 8012af9

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java

+3-12
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.openqa.selenium.remote.service.DriverService;
5252

5353
import java.net.URI;
54-
import java.net.URISyntaxException;
5554
import java.nio.file.Path;
5655
import java.util.Optional;
5756
import java.util.ServiceLoader;
@@ -207,17 +206,9 @@ private FirefoxDriver(FirefoxDriverCommandExecutor executor, FirefoxOptions opti
207206
webStorage = new RemoteWebStorage(getExecuteMethod());
208207

209208
Capabilities capabilities = super.getCapabilities();
210-
Optional<URI> cdpUri = Optional.empty();
211-
if (capabilities.getCapability("moz:debuggerAddress") instanceof String) {
212-
try {
213-
URI providedUri = new URI(String.format("http://%s", capabilities.getCapability("moz:debuggerAddress")));
214-
HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
215-
216-
cdpUri = CdpEndpointFinder.getCdpEndPoint(clientFactory, providedUri);
217-
} catch (RuntimeException | URISyntaxException e) {
218-
// Swallow the exception.
219-
}
220-
}
209+
HttpClient.Factory clientFactory = HttpClient.Factory.createDefault();
210+
Optional<URI> cdpUri = CdpEndpointFinder.getReportedUri("moz:debuggerAddress", capabilities)
211+
.flatMap(reported -> CdpEndpointFinder.getCdpEndPoint(clientFactory, reported));
221212

222213
this.cdpUri = cdpUri;
223214
this.capabilities = cdpUri.map(uri ->

java/server/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java

+3-12
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.openqa.selenium.remote.tracing.Tracer;
4747

4848
import java.net.URI;
49-
import java.net.URISyntaxException;
5049
import java.net.URL;
5150
import java.time.Instant;
5251
import java.util.HashMap;
@@ -206,17 +205,9 @@ public DevToolsInfo(URI cdpEndpoint, String version) {
206205
CdpEndpointFinder.getReportedUri("ms:edgeOptions", c)
207206
.map(uri -> new DevToolsInfo(uri, c.getBrowserVersion()));
208207

209-
Function<Capabilities, Optional<DevToolsInfo>> firefox = c -> {
210-
Object address = c.getCapability("moz:debuggerAddress");
211-
return Optional.ofNullable(address).map(adr -> {
212-
try {
213-
URI uri = new URI(String.format("http://%s", adr));
214-
return new DevToolsInfo(uri, "86");
215-
} catch (URISyntaxException e) {
216-
return null;
217-
}
218-
});
219-
};
208+
Function<Capabilities, Optional<DevToolsInfo>> firefox = c ->
209+
CdpEndpointFinder.getReportedUri("moz:debuggerAddress", c)
210+
.map(uri -> new DevToolsInfo(uri, "86"));
220211

221212
Optional<DevToolsInfo> maybeInfo = Stream.of(chrome, edge, firefox)
222213
.map(finder -> finder.apply(caps))

0 commit comments

Comments
 (0)