Skip to content

Commit 98e293b

Browse files
authored
Update to Selenium 4.31.0 +semver:feature (#268)
Update other package references replace JsonNode with JsonElement? references removed CDP V85 references as they are no longer supported by Firefox and Selenium Update tasks in azure-pipelines yml update license year
1 parent b660936 commit 98e293b

File tree

10 files changed

+75
-47
lines changed

10 files changed

+75
-47
lines changed

Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>selenium webdriver browser automation image locator</PackageTags>
1515
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
17-
<Copyright>Copyright 2024 Aquality Automation</Copyright>
17+
<Copyright>Copyright 2025 Aquality Automation</Copyright>
1818
<IsPackable>true</IsPackable>
1919
</PropertyGroup>
2020

Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageTags>selenium webdriver browser automation</PackageTags>
1616
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1717
<PackageReadmeFile>README.md</PackageReadmeFile>
18-
<Copyright>Copyright 2024 Aquality Automation</Copyright>
18+
<Copyright>Copyright 2025 Aquality Automation</Copyright>
1919
<IsPackable>true</IsPackable>
2020
</PropertyGroup>
2121

@@ -91,8 +91,8 @@
9191
</ItemGroup>
9292

9393
<ItemGroup>
94-
<PackageReference Include="Aquality.Selenium.Core" Version="3.1.3" />
95-
<PackageReference Include="WebDriverManager" Version="2.17.4" />
94+
<PackageReference Include="Aquality.Selenium.Core" Version="3.2.1" />
95+
<PackageReference Include="WebDriverManager" Version="2.17.5" />
9696
</ItemGroup>
9797

9898
</Project>

Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsEmulationExtensions.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using Aquality.Selenium.Core.Utilities;
22
using OpenQA.Selenium.DevTools;
3-
using OpenQA.Selenium.DevTools.V85.DOM;
4-
using OpenQA.Selenium.DevTools.V85.Emulation;
3+
using OpenQA.Selenium.DevTools.V135.DOM;
4+
using OpenQA.Selenium.DevTools.V135.Emulation;
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Text.Json;
89
using System.Threading.Tasks;
910

1011
namespace Aquality.Selenium.Browsers
@@ -24,7 +25,10 @@ public static class DevToolsEmulationExtensions
2425
public static async Task<bool> CanEmulate(this DevToolsHandling devTools)
2526
{
2627
var response = await devTools.SendCommand(new CanEmulateCommandSettings());
27-
return response["result"]?.ToString().Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase) == true;
28+
return response.HasValue && response.Value.TryGetProperty("result", out JsonElement resultElement)
29+
&& (resultElement.ValueKind == JsonValueKind.True ||
30+
(resultElement.ValueKind == JsonValueKind.String &&
31+
resultElement.GetString().Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase)));
2832
}
2933

3034
/// <summary>

Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public object ExecuteCdpCommand(string commandName, Dictionary<string, object> c
117117
{
118118
LogCommand(commandName, JsonSerializer.SerializeToNode(commandParameters), loggingOptions);
119119
var result = driver.ExecuteCdpCommand(commandName, commandParameters);
120-
var formattedResult = JsonSerializer.SerializeToNode(result);
120+
var formattedResult = JsonSerializer.SerializeToElement(result);
121121
LogCommandResult(formattedResult, loggingOptions);
122122
return result;
123123
}
@@ -136,8 +136,8 @@ public object ExecuteCdpCommand(string commandName, Dictionary<string, object> c
136136
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
137137
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
138138
/// <param name="loggingOptions">Logging preferences.</param>
139-
/// <returns>A JsonNode based on a command created with the specified command name and parameters.</returns>
140-
public async Task<JsonNode> SendCommand(string commandName, JsonNode commandParameters = null,
139+
/// <returns>A JsonElement? based on a command created with the specified command name and parameters.</returns>
140+
public async Task<JsonElement?> SendCommand(string commandName, JsonNode commandParameters = null,
141141
CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true,
142142
DevToolsCommandLoggingOptions loggingOptions = null)
143143
{
@@ -157,8 +157,8 @@ public async Task<JsonNode> SendCommand(string commandName, JsonNode commandPara
157157
/// <param name="millisecondsTimeout">The execution timeout of the command in milliseconds.</param>
158158
/// <param name="throwExceptionIfResponseNotReceived"><see langword="true"/> to throw an exception if a response is not received; otherwise, <see langword="false"/>.</param>
159159
/// <param name="loggingOptions">Logging preferences.</param>
160-
/// <returns>A JsonNode based on a command created with the specified command name and parameters.</returns>
161-
public async Task<JsonNode> SendCommand(ICommand commandWithParameters,
160+
/// <returns>A JsonElement? based on a command created with the specified command name and parameters.</returns>
161+
public async Task<JsonElement?> SendCommand(ICommand commandWithParameters,
162162
CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true,
163163
DevToolsCommandLoggingOptions loggingOptions = null)
164164
{
@@ -183,7 +183,7 @@ protected virtual void LogCommand(string commandName, JsonNode commandParameters
183183
}
184184
}
185185

186-
protected virtual void LogCommandResult(JsonNode result, DevToolsCommandLoggingOptions loggingOptions = null)
186+
protected virtual void LogCommandResult(JsonElement? result, DevToolsCommandLoggingOptions loggingOptions = null)
187187
{
188188
var logging = (loggingOptions ?? new DevToolsCommandLoggingOptions()).Result;
189189
if (IsNotEmpty(result) && logging.Enabled)
@@ -192,6 +192,31 @@ protected virtual void LogCommandResult(JsonNode result, DevToolsCommandLoggingO
192192
}
193193
}
194194

195+
private static bool IsNotEmpty(JsonElement? jsonElement)
196+
{
197+
if (!jsonElement.HasValue)
198+
{
199+
return false;
200+
}
201+
202+
var element = jsonElement.Value;
203+
switch (element.ValueKind)
204+
{
205+
case JsonValueKind.Object:
206+
return element.EnumerateObject().Any();
207+
case JsonValueKind.Array:
208+
return element.EnumerateArray().Any();
209+
case JsonValueKind.String:
210+
return !string.IsNullOrEmpty(element.GetString());
211+
case JsonValueKind.Number:
212+
case JsonValueKind.True:
213+
case JsonValueKind.False:
214+
return true;
215+
default:
216+
return false;
217+
}
218+
}
219+
195220
private static bool IsNotEmpty(JsonNode jsonNode)
196221
{
197222
return jsonNode is JsonArray array ? array.Any() : (jsonNode as JsonObject).Any();

Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsPerformanceExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using OpenQA.Selenium.DevTools.V85.Performance;
1+
using OpenQA.Selenium.DevTools.V135.Performance;
22
using System.Collections.Generic;
33
using System.Globalization;
44
using System.Linq;
5-
using System.Text.Json.Nodes;
5+
using System.Text.Json;
66
using System.Threading.Tasks;
77

88
namespace Aquality.Selenium.Browsers
@@ -42,9 +42,9 @@ public static async Task EnablePerformanceMonitoring(this DevToolsHandling devTo
4242
/// <returns>A task for asynchronous command with current values for run-time metrics as result.</returns>
4343
public static async Task<IDictionary<string, double>> GetPerformanceMetrics(this DevToolsHandling devTools)
4444
{
45-
JsonNode result = await devTools.SendCommand(new GetMetricsCommandSettings());
46-
return (result["metrics"].AsArray())
47-
.ToDictionary(item => item["name"].ToString(), item => double.Parse(item["value"].ToString(), CultureInfo.InvariantCulture));
45+
JsonElement? result = await devTools.SendCommand(new GetMetricsCommandSettings());
46+
return (result.Value.GetProperty("metrics").EnumerateArray())
47+
.ToDictionary(item => item.GetProperty("name").ToString(), item => double.Parse(item.GetProperty("value").ToString(), CultureInfo.InvariantCulture));
4848
}
4949
}
5050
}

Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
</ItemGroup>
3030

3131
<ItemGroup>
32-
<PackageReference Include="nunit" Version="4.2.2" />
33-
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
32+
<PackageReference Include="nunit" Version="4.3.2" />
33+
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0">
3434
<PrivateAssets>all</PrivateAssets>
3535
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3636
</PackageReference>
37-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
37+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
3838
</ItemGroup>
3939

4040
<ItemGroup>

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;
66
using NUnit.Framework;
77
using OpenQA.Selenium;
8-
using OpenQA.Selenium.DevTools.V85.Emulation;
8+
using OpenQA.Selenium.DevTools.V135.Emulation;
99
using System;
1010
using System.Collections.Generic;
1111

@@ -59,11 +59,11 @@ public void Should_BePossibleTo_SetAndClearDeviceMetricsOverride_WithVersionSpec
5959
{
6060
void setAction(long width, long height, bool isMobile, double scaleFactor)
6161
{
62-
var parameters = new OpenQA.Selenium.DevTools.V131.Emulation.SetDeviceMetricsOverrideCommandSettings
62+
var parameters = new OpenQA.Selenium.DevTools.V134.Emulation.SetDeviceMetricsOverrideCommandSettings
6363
{
64-
DisplayFeature = new OpenQA.Selenium.DevTools.V131.Emulation.DisplayFeature
64+
DisplayFeature = new OpenQA.Selenium.DevTools.V134.Emulation.DisplayFeature
6565
{
66-
Orientation = OpenQA.Selenium.DevTools.V131.Emulation.DisplayFeatureOrientationValues.Horizontal
66+
Orientation = OpenQA.Selenium.DevTools.V134.Emulation.DisplayFeatureOrientationValues.Horizontal
6767
},
6868
Width = width,
6969
Height = height,

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2024 Aquality Automation
189+
Copyright 2025 Aquality Automation
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

azure-pipelines.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,34 @@ stages:
1212

1313
jobs:
1414
- job: sonar
15-
displayName: Analyse code with SonarQube
15+
displayName: Analyze code with SonarQube
1616

1717
steps:
18-
- task: SonarCloudPrepare@2
18+
- task: SonarCloudPrepare@3
1919
displayName: 'Prepare SonarCloud analysis'
2020
inputs:
2121
SonarCloud: 'SonarCloud'
2222
organization: 'aqualityautomation'
23-
scannerMode: 'MSBuild'
23+
scannerMode: 'dotnet'
2424
projectKey: 'aquality-automation_aquality-selenium-dotnet'
2525
projectName: 'aquality-selenium-dotnet'
2626
projectVersion: '$(Build.BuildNumber)'
27-
extraProperties: |
28-
sonar.coverage.exclusions=**/**
27+
extraProperties: 'sonar.coverage.exclusions=**/**'
2928

3029
- task: DotNetCoreCLI@2
3130
displayName: 'Build solution'
32-
env:
33-
MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912
3431
inputs:
3532
command: 'build'
3633
projects: Aquality.Selenium/Aquality.Selenium.sln
3734
arguments: -c $(buildConfiguration)
3835

39-
- task: SonarCloudAnalyze@2
40-
displayName: 'Run SonarCloud code analysis'
41-
continueOnError: true
36+
- task: SonarCloudAnalyze@3
4237
inputs:
4338
jdkversion: 'JAVA_HOME_17_X64'
39+
displayName: 'Run SonarCloud code analysis'
40+
continueOnError: true
4441

45-
- task: SonarCloudPublish@2
42+
- task: SonarCloudPublish@3
4643
displayName: 'Publish SonarCloud quality gate results'
4744
inputs:
4845
pollingTimeoutSec: '300'
@@ -83,16 +80,18 @@ stages:
8380
- script: dotnet pack Aquality.Selenium\Aquality.Selenium.sln -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory)
8481
displayName: 'Pack to NuGet package'
8582

86-
- task: GitHubRelease@0
83+
- task: GitHubRelease@1
8784
displayName: 'Create tag on GitHub'
8885
inputs:
8986
gitHubConnection: 'github.com_aqualityautomation'
9087
repositoryName: 'aquality-automation/aquality-selenium-dotnet'
9188
action: 'create'
89+
target: '$(Build.SourceVersion)'
90+
tagSource: 'userSpecifiedTag'
9291
tag: 'v$(GitVersion.NuGetVersion)'
93-
title: 'v$(GitVersion.NuGetVersion)'
94-
tagSource: 'manual'
95-
isPreRelease: contains(variables['GitVersion.NuGetVersion'], '-')
92+
isDraft: contains(variables['GitVersion.NuGetVersion'], '-')
93+
changeLogCompareToRelease: 'lastFullRelease'
94+
changeLogType: 'commitBased'
9695

9796
- task: NuGetCommand@2
9897
displayName: 'Push NuGet package'

0 commit comments

Comments
 (0)