Skip to content

Commit 85f1ccb

Browse files
authored
Merge branch 'trunk' into network
2 parents dffdddb + 04f9e9f commit 85f1ccb

File tree

24 files changed

+70
-345
lines changed

24 files changed

+70
-345
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bazel_dep(name = "platforms", version = "0.0.11")
1515
bazel_dep(name = "protobuf", version = "29.2", dev_dependency = True, repo_name = "com_google_protobuf")
1616

1717
# Required for rules_rust to import the crates properly
18-
bazel_dep(name = "rules_cc", version = "0.1.0", dev_dependency = True)
18+
bazel_dep(name = "rules_cc", version = "0.1.1", dev_dependency = True)
1919

2020
bazel_dep(name = "rules_dotnet", version = "0.17.5")
2121
bazel_dep(name = "rules_java", version = "8.7.1")

dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// under the License.
1818
// </copyright>
1919

20-
using OpenQA.Selenium.BiDi.Modules.BrowsingContext;
2120
using System;
2221
using System.Threading.Tasks;
2322

@@ -44,13 +43,4 @@ public static async Task<BiDi> AsBiDiAsync(this IWebDriver webDriver)
4443

4544
return bidi;
4645
}
47-
48-
public static async Task<BrowsingContext> AsBiDiContextAsync(this IWebDriver webDriver)
49-
{
50-
var bidi = await webDriver.AsBiDiAsync();
51-
52-
var currentBrowsingContext = new BrowsingContext(bidi, webDriver.CurrentWindowHandle);
53-
54-
return currentBrowsingContext;
55-
}
5646
}

dotnet/src/webdriver/Remote/HttpCommandExecutor.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,39 @@ protected virtual void OnSendingRemoteHttpRequest(SendingRemoteHttpRequestEventA
221221
this.SendingRemoteHttpRequest?.Invoke(this, eventArgs);
222222
}
223223

224-
private HttpClient CreateHttpClient()
224+
/// <summary>
225+
/// Creates an instance of <see cref="HttpClientHandler"/> as underlying handler,
226+
/// used by <see cref="CreateHttpClient"/>. Invoked only once when required.
227+
/// </summary>
228+
/// <returns>An instance of <see cref="HttpClientHandler"/>.</returns>
229+
protected virtual HttpClientHandler CreateHttpClientHandler()
225230
{
226-
HttpClientHandler httpClientHandler = new HttpClientHandler();
231+
HttpClientHandler httpClientHandler = new();
232+
227233
string userInfo = this.remoteServerUri.UserInfo;
228-
if (!string.IsNullOrEmpty(userInfo) && userInfo.Contains(":"))
234+
235+
if (!string.IsNullOrEmpty(userInfo) && userInfo.Contains(':'))
229236
{
230-
string[] userInfoComponents = this.remoteServerUri.UserInfo.Split(new char[] { ':' }, 2);
237+
string[] userInfoComponents = this.remoteServerUri.UserInfo.Split([':'], 2);
231238
httpClientHandler.Credentials = new NetworkCredential(userInfoComponents[0], userInfoComponents[1]);
232239
httpClientHandler.PreAuthenticate = true;
233240
}
234241

235242
httpClientHandler.Proxy = this.Proxy;
236243

244+
return httpClientHandler;
245+
}
246+
247+
/// <summary>
248+
/// Creates an instance of <see cref="HttpClient"/> used by making all HTTP calls to remote end.
249+
/// Invoked only once when required.
250+
/// </summary>
251+
/// <returns>An instance of <see cref="HttpClient"/>.</returns>
252+
protected virtual HttpClient CreateHttpClient()
253+
{
254+
var httpClientHandler = CreateHttpClientHandler()
255+
?? throw new InvalidOperationException($"{nameof(CreateHttpClientHandler)} method returned null");
256+
237257
HttpMessageHandler handler = httpClientHandler;
238258

239259
if (_logger.IsEnabled(LogEventLevel.Trace))
@@ -242,15 +262,18 @@ private HttpClient CreateHttpClient()
242262
}
243263

244264
var client = new HttpClient(handler);
265+
245266
client.DefaultRequestHeaders.UserAgent.ParseAdd(this.UserAgent);
246267
client.DefaultRequestHeaders.Accept.ParseAdd(RequestAcceptHeader);
247268
client.DefaultRequestHeaders.ExpectContinue = false;
269+
248270
if (!this.IsKeepAliveEnabled)
249271
{
250272
client.DefaultRequestHeaders.Connection.ParseAdd("close");
251273
}
252274

253275
client.Timeout = this.serverResponseTimeout;
276+
254277
return client;
255278
}
256279

dotnet/test/common/BiDi/BiDiFixture.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ public async Task BiDiSetUp()
4444

4545
driver = EnvironmentManager.Instance.CreateDriverInstance(options);
4646

47-
context = await driver.AsBiDiContextAsync();
48-
bidi = context.BiDi;
47+
bidi = await driver.AsBiDiAsync();
48+
49+
context = (await bidi.BrowsingContext.GetTreeAsync())[0].Context;
4950
}
5051

5152
[TearDown]

java/spotbugs-excludes.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@
139139
<Class name="org.openqa.selenium.json.JsonInputIterator"/>
140140
<Bug pattern="IT_NO_SUCH_ELEMENT"/>
141141
</Match>
142-
143-
<Match>
144-
<Class name="org.openqa.selenium.mobile.NetworkConnection$ConnectionType"/>
145-
<Bug pattern="IM_BAD_CHECK_FOR_ODD"/>
146-
</Match>
147-
142+
148143
<Match>
149144
<Class name="org.openqa.selenium.net.NetworkUtils"/>
150145
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>

java/src/org/openqa/selenium/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ java_export(
1717
"internal/*.java",
1818
"interactions/**/*.java",
1919
"logging/**/*.java",
20-
"mobile/*.java",
2120
"net/*.java",
2221
"virtualauthenticator/*.java",
2322
"print/*.java",

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import org.openqa.selenium.json.TypeToken;
6262
import org.openqa.selenium.logging.EventType;
6363
import org.openqa.selenium.logging.HasLogEvents;
64-
import org.openqa.selenium.mobile.NetworkConnection;
6564
import org.openqa.selenium.remote.CommandExecutor;
6665
import org.openqa.selenium.remote.FileDetector;
6766
import org.openqa.selenium.remote.RemoteWebDriver;
@@ -70,7 +69,6 @@
7069
import org.openqa.selenium.remote.http.ClientConfig;
7170
import org.openqa.selenium.remote.http.ConnectionFailedException;
7271
import org.openqa.selenium.remote.http.HttpClient;
73-
import org.openqa.selenium.remote.mobile.RemoteNetworkConnection;
7472

7573
/**
7674
* A {@link WebDriver} implementation that controls a Chromium browser running on the local machine.
@@ -87,7 +85,6 @@ public class ChromiumDriver extends RemoteWebDriver
8785
HasNetworkConditions,
8886
HasPermissions,
8987
LocationContext,
90-
NetworkConnection,
9188
WebStorage {
9289

9390
public static final Predicate<String> IS_CHROMIUM_BROWSER =
@@ -97,7 +94,6 @@ public class ChromiumDriver extends RemoteWebDriver
9794
private final Capabilities capabilities;
9895
private final RemoteLocationContext locationContext;
9996
private final RemoteWebStorage webStorage;
100-
private final RemoteNetworkConnection networkConnection;
10197
private final HasNetworkConditions networkConditions;
10298
private final HasPermissions permissions;
10399
private final HasLaunchApp launch;
@@ -115,7 +111,6 @@ protected ChromiumDriver(
115111
locationContext = new RemoteLocationContext(getExecuteMethod());
116112
webStorage = new RemoteWebStorage(getExecuteMethod());
117113
permissions = new AddHasPermissions().getImplementation(getCapabilities(), getExecuteMethod());
118-
networkConnection = new RemoteNetworkConnection(getExecuteMethod());
119114
networkConditions =
120115
new AddHasNetworkConditions().getImplementation(getCapabilities(), getExecuteMethod());
121116
launch = new AddHasLaunchApp().getImplementation(getCapabilities(), getExecuteMethod());
@@ -317,19 +312,6 @@ public void setLocation(Location location) {
317312
locationContext.setLocation(location);
318313
}
319314

320-
@Override
321-
@Deprecated
322-
public ConnectionType getNetworkConnection() {
323-
return networkConnection.getNetworkConnection();
324-
}
325-
326-
@Override
327-
@Deprecated
328-
public ConnectionType setNetworkConnection(ConnectionType type) {
329-
Require.nonNull("Network Connection Type", type);
330-
return networkConnection.setNetworkConnection(type);
331-
}
332-
333315
@Override
334316
public void launchApp(String id) {
335317
Require.nonNull("Launch App ID", id);

java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@ public static Optional<URI> getReportedUri(Capabilities caps) {
8989
case "msedge":
9090
key = "ms:edgeOptions";
9191
break;
92-
case "firefox":
93-
key = "moz:debuggerAddress";
94-
if (!caps.is("webSocketUrl")) {
95-
LOG.warning(
96-
"CDP support for Firefox is deprecated and will be removed in future versions. "
97-
+ "Please switch to WebDriver BiDi.");
98-
}
99-
break;
10092
default:
10193
return Optional.empty();
10294
}

java/src/org/openqa/selenium/firefox/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ java_export(
1313
deps = [
1414
"//java:auto-service",
1515
"//java/src/org/openqa/selenium/bidi",
16-
"//java/src/org/openqa/selenium/devtools/v85",
1716
"//java/src/org/openqa/selenium/json",
1817
"//java/src/org/openqa/selenium/manager",
1918
"//java/src/org/openqa/selenium/remote",

java/src/org/openqa/selenium/mobile/NetworkConnection.java

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)