-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] [bidi] Support network collectors and get response body #16192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nvborisenko
merged 8 commits into
SeleniumHQ:trunk
from
nvborisenko:dotnet-bidi-getdata
Sep 17, 2025
+296
−1
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b605190
Get response body
nvborisenko 373fd9a
Decrease max total data size
nvborisenko b9ea380
One to one string conversion
nvborisenko eeae5a8
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-getdata
nvborisenko 9d35b40
Return back explicit conversion to string
nvborisenko 5f001b0
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-getdata
nvborisenko 19706c9
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-getdata
nvborisenko b67f3e8
Remove hardcoded chrome version
nvborisenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Get response body
- Loading branch information
commit b6051902551819a306391faa20853b6edc15b0b2
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
dotnet/src/webdriver/BiDi/Communication/Json/Converters/CollectorConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// <copyright file="CollectorConverter.cs" company="Selenium Committers"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using OpenQA.Selenium.BiDi.Network; | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters; | ||
|
||
internal class CollectorConverter : JsonConverter<Collector> | ||
{ | ||
private readonly BiDi _bidi; | ||
|
||
public CollectorConverter(BiDi bidi) | ||
{ | ||
_bidi = bidi; | ||
} | ||
|
||
public override Collector? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var id = reader.GetString(); | ||
|
||
return new Collector(_bidi, id!); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, Collector value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Id); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
dotnet/src/webdriver/BiDi/Network/AddDataCollectorCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <copyright file="AddDataCollectorCommand.cs" company="Selenium Committers"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using System.Collections.Generic; | ||
using OpenQA.Selenium.BiDi.Communication; | ||
|
||
namespace OpenQA.Selenium.BiDi.Network; | ||
|
||
internal sealed class AddDataCollectorCommand(AddDataCollectorParameters @params) | ||
: Command<AddDataCollectorParameters, AddDataCollectorResult>(@params, "network.addDataCollector"); | ||
|
||
internal sealed record AddDataCollectorParameters(IEnumerable<DataType> DataTypes, int MaxEncodedDataSize, CollectorType? CollectorType, IEnumerable<BrowsingContext.BrowsingContext>? Contexts, IEnumerable<Browser.UserContext>? UserContexts) : Parameters; | ||
|
||
public class AddDataCollectorOptions : CommandOptions | ||
{ | ||
public CollectorType? CollectorType { get; set; } | ||
|
||
public IEnumerable<BrowsingContext.BrowsingContext>? Contexts { get; set; } | ||
|
||
public IEnumerable<Browser.UserContext>? UserContexts { get; set; } | ||
} | ||
|
||
public sealed record AddDataCollectorResult(Collector Collector) : EmptyResult; | ||
|
||
public enum DataType | ||
{ | ||
Response | ||
} | ||
|
||
public enum CollectorType | ||
{ | ||
Blob | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// <copyright file="Collector.cs" company="Selenium Committers"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenQA.Selenium.BiDi.Network; | ||
|
||
public sealed class Collector : IAsyncDisposable | ||
{ | ||
private readonly BiDi _bidi; | ||
|
||
internal Collector(BiDi bidi, string id) | ||
{ | ||
_bidi = bidi; | ||
Id = id; | ||
} | ||
|
||
internal string Id { get; } | ||
|
||
public async Task RemoveAsync() | ||
{ | ||
await _bidi.Network.RemoveDataCollectorAsync(this).ConfigureAwait(false); | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
await RemoveAsync(); | ||
} | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
if (obj is Collector collectortObj) return collectortObj.Id == Id; | ||
|
||
return false; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return Id.GetHashCode(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// <copyright file="GetDataCommand.cs" company="Selenium Committers"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using OpenQA.Selenium.BiDi.Communication; | ||
|
||
namespace OpenQA.Selenium.BiDi.Network; | ||
|
||
internal sealed class GetDataCommand(GetDataParameters @params) | ||
: Command<GetDataParameters, GetDataResult>(@params, "network.getData"); | ||
|
||
internal sealed record GetDataParameters(DataType DataType, Request Request, Collector? Collector, bool? Disown) : Parameters; | ||
|
||
public sealed class GetDataOptions : CommandOptions | ||
{ | ||
public Collector? Collector { get; set; } | ||
|
||
public bool? Disown { get; set; } | ||
} | ||
|
||
public sealed record GetDataResult(BytesValue Bytes) : EmptyResult; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
dotnet/src/webdriver/BiDi/Network/RemoveDataCollectorCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// <copyright file="RemoveDataCollectorCommand.cs" company="Selenium Committers"> | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// </copyright> | ||
|
||
using OpenQA.Selenium.BiDi.Communication; | ||
|
||
namespace OpenQA.Selenium.BiDi.Network; | ||
|
||
internal sealed class RemoveDataCollectorCommand(RemoveDataCollectorParameters @params) | ||
: Command<RemoveDataCollectorParameters, EmptyResult>(@params, "network.removeDataCollector"); | ||
|
||
internal sealed record RemoveDataCollectorParameters(Collector Collector) : Parameters; | ||
|
||
public class RemoveDataCollectorOptions : CommandOptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.