Skip to content

Commit 4bf1d68

Browse files
vlad8x8diemol
andauthored
[java] Webdriver can work with embedded apps without CDP (#11963)
* Connection can be empty for embedded apps Webdriver for New MS Teams can start only added an argument `remote-debugging-port=<any number>` to EdgeOptions. But Teams is actually staring at random port and ChromiumDriver is failing to create a connection. If the connection is empty, Teams starts well and webdriver can interact with Teams well. * Update ChromiumDriver.java class comment * Make connection not final * Applying formatter --------- Co-authored-by: Diego Molina <[email protected]> Co-authored-by: Diego Molina <[email protected]>
1 parent 1c171e7 commit 4bf1d68

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

java/src/org/openqa/selenium/chromium/ChromiumDriver.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@
5858
import org.openqa.selenium.remote.html5.RemoteLocationContext;
5959
import org.openqa.selenium.remote.html5.RemoteWebStorage;
6060
import org.openqa.selenium.remote.http.ClientConfig;
61+
import org.openqa.selenium.remote.http.ConnectionFailedException;
6162
import org.openqa.selenium.remote.http.HttpClient;
6263
import org.openqa.selenium.remote.mobile.RemoteNetworkConnection;
6364

6465
/**
6566
* A {@link WebDriver} implementation that controls a Chromium browser running on the local machine.
66-
* It is used as the base class for Chromium-based browser drivers (Chrome, Edgium).
67+
* It is used as the base class for Chromium-based browser drivers (Chrome, Edge).
6768
*/
6869
public class ChromiumDriver extends RemoteWebDriver
6970
implements HasAuthentication,
@@ -89,7 +90,7 @@ public class ChromiumDriver extends RemoteWebDriver
8990
private final HasNetworkConditions networkConditions;
9091
private final HasPermissions permissions;
9192
private final HasLaunchApp launch;
92-
private final Optional<Connection> connection;
93+
private Optional<Connection> connection;
9394
private final Optional<DevTools> devTools;
9495
protected HasCasting casting;
9596
protected HasCdp cdp;
@@ -111,12 +112,17 @@ protected ChromiumDriver(
111112
CdpEndpointFinder.getReportedUri(capabilityKey, originalCapabilities)
112113
.flatMap(uri -> CdpEndpointFinder.getCdpEndPoint(factory, uri));
113114

114-
connection =
115-
cdpUri.map(
116-
uri ->
117-
new Connection(
118-
factory.createClient(ClientConfig.defaultConfig().baseUri(uri)),
119-
uri.toString()));
115+
try {
116+
connection =
117+
cdpUri.map(
118+
uri ->
119+
new Connection(
120+
factory.createClient(ClientConfig.defaultConfig().baseUri(uri)),
121+
uri.toString()));
122+
} catch (ConnectionFailedException e) {
123+
LOG.warning("Unable to establish websocket connection to " + cdpUri.get());
124+
connection = Optional.empty();
125+
}
120126

121127
CdpInfo cdpInfo =
122128
new CdpVersionFinder()

0 commit comments

Comments
 (0)