Skip to content

Commit 2819469

Browse files
authored
Merge branch 'trunk' into syber911911-feature-branch
2 parents db511e2 + 215e20b commit 2819469

File tree

80 files changed

+6240
-2027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+6240
-2027
lines changed

.github/workflows/ci-dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ jobs:
2323
java-version: 17
2424
os: windows
2525
run: |
26+
fsutil 8dot3name set 0
2627
bazel test //dotnet/test/common:ElementFindingTest-firefox //dotnet/test/common:ElementFindingTest-chrome --pin_browsers=true

.github/workflows/ci-java.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
# https://github.com/bazelbuild/rules_jvm_external/issues/1046
2323
java-version: 17
2424
run: |
25+
fsutil 8dot3name set 0
2526
bazel test --flaky_test_attempts 3 //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest `
2627
//java/test/org/openqa/selenium/federatedcredentialmanagement:FederatedCredentialManagementTest `
2728
//java/test/org/openqa/selenium/firefox:FirefoxDriverBuilderTest `

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ maven.install(
173173
"com.github.spotbugs:spotbugs:4.8.6",
174174
"com.github.stephenc.jcip:jcip-annotations:1.0-1",
175175
"com.google.code.gson:gson:2.11.0",
176-
"com.google.guava:guava:33.3.0-jre",
176+
"com.google.guava:guava:33.3.1-jre",
177177
"com.google.auto:auto-common:1.2.2",
178178
"com.google.auto.service:auto-service:1.1.1",
179179
"com.google.auto.service:auto-service-annotations:1.1.1",

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ rules_closure_toolchains()
3434

3535
http_archive(
3636
name = "rules_rust",
37-
integrity = "sha256-JLN47ZcAbx9wEr5Jiib4HduZATGLiDgK7oUi/fvotzU=",
38-
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.42.1/rules_rust-v0.42.1.tar.gz"],
37+
integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
38+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
3939
)
4040

4141
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
89 Bytes
Binary file not shown.

common/extensions/webextensions-selenium-example/manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
]
1515
}
1616
],
17+
"permissions": [
18+
"storage",
19+
"scripting"
20+
],
21+
"host_permissions": [
22+
"https://*/*",
23+
"http://*/*"
24+
],
1725
"browser_specific_settings": {
1826
"gecko": {
1927

dotnet/src/webdriver/NetworkManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public NetworkManager(IWebDriver driver)
4545
this.session = new Lazy<DevToolsSession>(() =>
4646
{
4747
IDevTools devToolsDriver = driver as IDevTools;
48-
if (session == null)
48+
if (devToolsDriver == null)
4949
{
5050
throw new WebDriverException("Driver must implement IDevTools to use these features");
5151
}

dotnet/src/webdriver/PrintOptions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,27 @@ public bool ShrinkToFit
101101
}
102102

103103
/// <summary>
104-
/// Gets the dimensions for each page in the printed document.
104+
/// Gets or sets the dimensions for each page in the printed document.
105105
/// </summary>
106106
public PageSize PageDimensions
107107
{
108108
get { return pageSize; }
109+
set
110+
{
111+
pageSize = value ?? throw new ArgumentNullException(nameof(value));
112+
}
109113
}
110114

111115
/// <summary>
112-
/// Gets the margins for each page in the doucment.
116+
/// Gets or sets the margins for each page in the doucment.
113117
/// </summary>
114118
public Margins PageMargins
115119
{
116120
get { return margins; }
121+
set
122+
{
123+
margins = value ?? throw new ArgumentNullException(nameof(value));
124+
}
117125
}
118126

119127
/// <summary>

dotnet/src/webdriver/SeleniumManager.cs

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
using System.Text;
2626
using System.Text.Json;
2727
using System.Text.Json.Serialization;
28+
using static OpenQA.Selenium.SeleniumManagerResponse;
29+
30+
#nullable enable
2831

2932
namespace OpenQA.Selenium
3033
{
@@ -36,27 +39,25 @@ public static class SeleniumManager
3639
{
3740
private static readonly ILogger _logger = Log.GetLogger(typeof(SeleniumManager));
3841

39-
private static readonly string BinaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
40-
4142
private static readonly JsonSerializerOptions _serializerOptions = new() { PropertyNameCaseInsensitive = true, TypeInfoResolver = SeleniumManagerSerializerContext.Default };
4243

43-
static SeleniumManager()
44+
private static readonly Lazy<string> _lazyBinaryFullPath = new(() =>
4445
{
45-
46-
if (BinaryFullPath == null)
46+
string? binaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
47+
if (binaryFullPath == null)
4748
{
4849
var currentDirectory = AppContext.BaseDirectory;
4950
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
5051
{
51-
BinaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "windows", "selenium-manager.exe");
52+
binaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "windows", "selenium-manager.exe");
5253
}
5354
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
5455
{
55-
BinaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "linux", "selenium-manager");
56+
binaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "linux", "selenium-manager");
5657
}
5758
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
5859
{
59-
BinaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "macos", "selenium-manager");
60+
binaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "macos", "selenium-manager");
6061
}
6162
else
6263
{
@@ -65,11 +66,13 @@ static SeleniumManager()
6566
}
6667
}
6768

68-
if (!File.Exists(BinaryFullPath))
69+
if (!File.Exists(binaryFullPath))
6970
{
70-
throw new WebDriverException($"Unable to locate or obtain Selenium Manager binary at {BinaryFullPath}");
71+
throw new WebDriverException($"Unable to locate or obtain Selenium Manager binary at {binaryFullPath}");
7172
}
72-
}
73+
74+
return binaryFullPath;
75+
});
7376

7477
/// <summary>
7578
/// Determines the location of the browser and driver binaries.
@@ -88,7 +91,7 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
8891
argsBuilder.Append(" --debug");
8992
}
9093

91-
var smCommandResult = RunCommand(BinaryFullPath, argsBuilder.ToString());
94+
var smCommandResult = RunCommand(_lazyBinaryFullPath.Value, argsBuilder.ToString());
9295
Dictionary<string, string> binaryPaths = new()
9396
{
9497
{ "browser_path", smCommandResult.BrowserPath },
@@ -112,10 +115,10 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
112115
/// <returns>
113116
/// the standard output of the execution.
114117
/// </returns>
115-
private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName, string arguments)
118+
private static ResultResponse RunCommand(string fileName, string arguments)
116119
{
117120
Process process = new Process();
118-
process.StartInfo.FileName = BinaryFullPath;
121+
process.StartInfo.FileName = _lazyBinaryFullPath.Value;
119122
process.StartInfo.Arguments = arguments;
120123
process.StartInfo.UseShellExecute = false;
121124
process.StartInfo.CreateNoWindow = true;
@@ -183,7 +186,7 @@ private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName
183186

184187
try
185188
{
186-
jsonResponse = JsonSerializer.Deserialize<SeleniumManagerResponse>(output, _serializerOptions);
189+
jsonResponse = JsonSerializer.Deserialize<SeleniumManagerResponse>(output, _serializerOptions)!;
187190
}
188191
catch (Exception ex)
189192
{
@@ -222,32 +225,19 @@ private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName
222225
}
223226
}
224227

225-
internal class SeleniumManagerResponse
228+
internal record SeleniumManagerResponse(IReadOnlyList<LogEntryResponse> Logs, ResultResponse Result)
226229
{
227-
public IReadOnlyList<LogEntryResponse> Logs { get; set; }
228-
229-
public ResultResponse Result { get; set; }
230-
231-
public class LogEntryResponse
232-
{
233-
public string Level { get; set; }
234-
235-
public string Message { get; set; }
236-
}
237-
238-
public class ResultResponse
239-
{
240-
[JsonPropertyName("driver_path")]
241-
public string DriverPath { get; set; }
242-
243-
[JsonPropertyName("browser_path")]
244-
public string BrowserPath { get; set; }
245-
}
230+
public record LogEntryResponse(string Level, string Message);
231+
232+
public record ResultResponse
233+
(
234+
[property: JsonPropertyName("driver_path")]
235+
string DriverPath,
236+
[property: JsonPropertyName("browser_path")]
237+
string BrowserPath
238+
);
246239
}
247240

248241
[JsonSerializable(typeof(SeleniumManagerResponse))]
249-
internal partial class SeleniumManagerSerializerContext : JsonSerializerContext
250-
{
251-
252-
}
242+
internal partial class SeleniumManagerSerializerContext : JsonSerializerContext;
253243
}

dotnet/src/webdriver/WebDriver.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
</Target>
107107

108108
<Target Name="GenerateCdp" BeforeTargets="CoreCompile">
109-
<Exec Command="bazel build //dotnet/src/webdriver/cdp:generate-v85 //dotnet/src/webdriver/cdp:generate-v127 //dotnet/src/webdriver/cdp:generate-v128 //dotnet/src/webdriver/cdp:generate-v129" WorkingDirectory="../../.." />
109+
<Exec Command="bazel build //dotnet/src/webdriver/cdp/..." WorkingDirectory="../../.." />
110110

111111
<ItemGroup>
112112
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\**\*.cs" LinkBase="DevTools\generated" />

0 commit comments

Comments
 (0)