Skip to content

Commit

Permalink
[dotnet][cdp] add support for Chrome 108 and remove support for Chrom…
Browse files Browse the repository at this point in the history
…e 105
  • Loading branch information
titusfortner committed Nov 30, 2022
1 parent 922f5d3 commit 285dace
Show file tree
Hide file tree
Showing 16 changed files with 201 additions and 198 deletions.
2 changes: 1 addition & 1 deletion dotnet/selenium-dotnet-version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0", "netstandard2.1", "net5.0",

SUPPORTED_DEVTOOLS_VERSIONS = [
"v85",
"v105",
"v106",
"v107",
"v108",
]

ASSEMBLY_COMPANY = "Selenium Committers"
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/DevToolsDomains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public abstract class DevToolsDomains
// added to this dictionary.
private static readonly Dictionary<int, Type> SupportedDevToolsVersions = new Dictionary<int, Type>()
{
{ 108, typeof(V108.V108Domains) },
{ 107, typeof(V107.V107Domains) },
{ 106, typeof(V106.V106Domains) },
{ 105, typeof(V105.V105Domains) },
{ 85, typeof(V85.V85Domains) }
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V105Domains.cs" company="WebDriver Committers">
// <copyright file="V108Domains.cs" company="WebDriver 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
Expand All @@ -19,24 +19,24 @@
using System.Collections.Generic;
using System.Text;

namespace OpenQA.Selenium.DevTools.V105
namespace OpenQA.Selenium.DevTools.V108
{
/// <summary>
/// Class containing the domain implementation for version 105 of the DevTools Protocol.
/// Class containing the domain implementation for version 108 of the DevTools Protocol.
/// </summary>
public class V105Domains : DevToolsDomains
public class V108Domains : DevToolsDomains
{
private DevToolsSessionDomains domains;

public V105Domains(DevToolsSession session)
public V108Domains(DevToolsSession session)
{
this.domains = new DevToolsSessionDomains(session);
}

/// <summary>
/// Gets the DevTools Protocol version for which this class is valid.
/// </summary>
public static int DevToolsVersion => 105;
public static int DevToolsVersion => 108;

/// <summary>
/// Gets the version-specific domains for the DevTools session. This value must be cast to a version specific type to be at all useful.
Expand All @@ -46,21 +46,21 @@ public V105Domains(DevToolsSession session)
/// <summary>
/// Gets the object used for manipulating network information in the browser.
/// </summary>
public override DevTools.Network Network => new V105Network(domains.Network, domains.Fetch);
public override DevTools.Network Network => new V108Network(domains.Network, domains.Fetch);

/// <summary>
/// Gets the object used for manipulating the browser's JavaScript execution.
/// </summary>
public override JavaScript JavaScript => new V105JavaScript(domains.Runtime, domains.Page);
public override JavaScript JavaScript => new V108JavaScript(domains.Runtime, domains.Page);

/// <summary>
/// Gets the object used for manipulating DevTools Protocol targets.
/// </summary>
public override DevTools.Target Target => new V105Target(domains.Target);
public override DevTools.Target Target => new V108Target(domains.Target);

/// <summary>
/// Gets the object used for manipulating the browser's logs.
/// </summary>
public override DevTools.Log Log => new V105Log(domains.Log);
public override DevTools.Log Log => new V108Log(domains.Log);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V105JavaScript.cs" company="WebDriver Committers">
// <copyright file="V108JavaScript.cs" company="WebDriver 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
Expand All @@ -18,25 +18,25 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V105.Page;
using OpenQA.Selenium.DevTools.V105.Runtime;
using OpenQA.Selenium.DevTools.V108.Page;
using OpenQA.Selenium.DevTools.V108.Runtime;

namespace OpenQA.Selenium.DevTools.V105
namespace OpenQA.Selenium.DevTools.V108
{
/// <summary>
/// Class containing the JavaScript implementation for version 105 of the DevTools Protocol.
/// Class containing the JavaScript implementation for version 108 of the DevTools Protocol.
/// </summary>
public class V105JavaScript : JavaScript
public class V108JavaScript : JavaScript
{
private RuntimeAdapter runtime;
private PageAdapter page;

/// <summary>
/// Initializes a new instance of the <see cref="V105JavaScript"/> class.
/// Initializes a new instance of the <see cref="V108JavaScript"/> class.
/// </summary>
/// <param name="runtime">The DevTools Protocol adapter for the Runtime domain.</param>
/// <param name="page">The DevTools Protocol adapter for the Page domain.</param>
public V105JavaScript(RuntimeAdapter runtime, PageAdapter page)
public V108JavaScript(RuntimeAdapter runtime, PageAdapter page)
{
this.runtime = runtime;
this.page = page;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V105Log.cs" company="WebDriver Committers">
// <copyright file="V108Log.cs" company="WebDriver 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
Expand All @@ -20,22 +20,22 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V105.Log;
using OpenQA.Selenium.DevTools.V108.Log;

namespace OpenQA.Selenium.DevTools.V105
namespace OpenQA.Selenium.DevTools.V108
{
/// <summary>
/// Class containing the browser's log as referenced by version 105 of the DevTools Protocol.
/// Class containing the browser's log as referenced by version 108 of the DevTools Protocol.
/// </summary>
public class V105Log : DevTools.Log
public class V108Log : DevTools.Log
{
private LogAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V105Log"/> class.
/// Initializes a new instance of the <see cref="V108Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
public V105Log(LogAdapter adapter)
public V108Log(LogAdapter adapter)
{
this.adapter = adapter;
this.adapter.EntryAdded += OnAdapterEntryAdded;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V105Network.cs" company="WebDriver Committers">
// <copyright file="V108Network.cs" company="WebDriver 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
Expand All @@ -20,25 +20,25 @@
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V105.Fetch;
using OpenQA.Selenium.DevTools.V105.Network;
using OpenQA.Selenium.DevTools.V108.Fetch;
using OpenQA.Selenium.DevTools.V108.Network;

namespace OpenQA.Selenium.DevTools.V105
namespace OpenQA.Selenium.DevTools.V108
{
/// <summary>
/// Class providing functionality for manipulating network calls using version 105 of the DevTools Protocol
/// Class providing functionality for manipulating network calls using version 108 of the DevTools Protocol
/// </summary>
public class V105Network : DevTools.Network
public class V108Network : DevTools.Network
{
private FetchAdapter fetch;
private NetworkAdapter network;

/// <summary>
/// Initializes a new instance of the <see cref="V105Network"/> class.
/// Initializes a new instance of the <see cref="V108Network"/> class.
/// </summary>
/// <param name="network">The adapter for the Network domain.</param>
/// <param name="fetch">The adapter for the Fetch domain.</param>
public V105Network(NetworkAdapter network, FetchAdapter fetch)
public V108Network(NetworkAdapter network, FetchAdapter fetch)
{
this.network = network;
this.fetch = fetch;
Expand Down Expand Up @@ -80,12 +80,12 @@ public override async Task DisableNetwork()
/// <returns>A task that represents the asynchronous operation.</returns>
public override async Task EnableFetchForAllPatterns()
{
await fetch.Enable(new OpenQA.Selenium.DevTools.V105.Fetch.EnableCommandSettings()
await fetch.Enable(new OpenQA.Selenium.DevTools.V108.Fetch.EnableCommandSettings()
{
Patterns = new OpenQA.Selenium.DevTools.V105.Fetch.RequestPattern[]
Patterns = new OpenQA.Selenium.DevTools.V108.Fetch.RequestPattern[]
{
new OpenQA.Selenium.DevTools.V105.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request },
new OpenQA.Selenium.DevTools.V105.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response }
new OpenQA.Selenium.DevTools.V108.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request },
new OpenQA.Selenium.DevTools.V108.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response }
},
HandleAuthRequests = true
});
Expand Down Expand Up @@ -208,9 +208,9 @@ public override async Task ContinueWithAuth(string requestId, string userName, s
await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
{
RequestId = requestId,
AuthChallengeResponse = new V105.Fetch.AuthChallengeResponse()
AuthChallengeResponse = new V108.Fetch.AuthChallengeResponse()
{
Response = V105.Fetch.AuthChallengeResponseResponseValues.ProvideCredentials,
Response = V108.Fetch.AuthChallengeResponseResponseValues.ProvideCredentials,
Username = userName,
Password = password
}
Expand All @@ -227,9 +227,9 @@ public override async Task CancelAuth(string requestId)
await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
{
RequestId = requestId,
AuthChallengeResponse = new OpenQA.Selenium.DevTools.V105.Fetch.AuthChallengeResponse()
AuthChallengeResponse = new OpenQA.Selenium.DevTools.V108.Fetch.AuthChallengeResponse()
{
Response = V105.Fetch.AuthChallengeResponseResponseValues.CancelAuth
Response = V108.Fetch.AuthChallengeResponseResponseValues.CancelAuth
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V105Target.cs" company="WebDriver Committers">
// <copyright file="V108Target.cs" company="WebDriver 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
Expand All @@ -21,22 +21,22 @@
using System.Collections.ObjectModel;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V105.Target;
using OpenQA.Selenium.DevTools.V108.Target;

namespace OpenQA.Selenium.DevTools.V105
namespace OpenQA.Selenium.DevTools.V108
{
/// <summary>
/// Class providing functionality for manipulating targets for version 105 of the DevTools Protocol
/// Class providing functionality for manipulating targets for version 108 of the DevTools Protocol
/// </summary>
public class V105Target : DevTools.Target
public class V108Target : DevTools.Target
{
private TargetAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V105Target"/> class.
/// Initializes a new instance of the <see cref="V108Target"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Target domain.</param>
public V105Target(TargetAdapter adapter)
public V108Target(TargetAdapter adapter)
{
this.adapter = adapter;
adapter.DetachedFromTarget += OnDetachedFromTarget;
Expand All @@ -51,9 +51,14 @@ public V105Target(TargetAdapter adapter)
/// targets available for this session.
/// </returns>
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null)

{
List<TargetInfo> targets = new List<TargetInfo>();
var response = await adapter.GetTargets();
if (settings == null)
{
settings = new GetTargetsCommandSettings();
}
var response = await adapter.GetTargets((GetTargetsCommandSettings) settings);
for (int i = 0; i < response.TargetInfos.Length; i++)
{
var targetInfo = response.TargetInfos[i];
Expand Down
14 changes: 7 additions & 7 deletions dotnet/src/webdriver/WebDriver.csproj.prebuild.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v85\DevToolsSession
popd
)

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v105\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 105
pushd "%1..\..\.."
bazel build //dotnet/src/webdriver/cdp:generate-v105
popd
)

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v106\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 106
pushd "%1..\..\.."
Expand All @@ -47,3 +40,10 @@ if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v107\DevToolsSessio
bazel build //dotnet/src/webdriver/cdp:generate-v107
popd
)

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v108\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 108
pushd "%1..\..\.."
bazel build //dotnet/src/webdriver/cdp:generate-v108
popd
)
12 changes: 6 additions & 6 deletions dotnet/src/webdriver/WebDriver.csproj.prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ then
bazel build //dotnet/src/webdriver/cdp:generate-v85
fi

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v105/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 105"
bazel build //dotnet/src/webdriver/cdp:generate-v105
fi

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v106/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 106"
Expand All @@ -40,3 +34,9 @@ then
echo "Generating CDP code for version 107"
bazel build //dotnet/src/webdriver/cdp:generate-v107
fi

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v108/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 108"
bazel build //dotnet/src/webdriver/cdp:generate-v108
fi
4 changes: 2 additions & 2 deletions dotnet/test/common/DevTools/DevToolsConsoleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class DevToolsConsoleTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyMessageAdded()
{
var domains = session.GetVersionSpecificDomains<V107.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V108.DevToolsSessionDomains>();
string consoleMessage = "Hello Selenium";

ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V107.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
EventHandler<V108.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
{
Assert.That(e.Message.Text, Is.EqualTo(consoleMessage));
sync.Set();
Expand Down
6 changes: 3 additions & 3 deletions dotnet/test/common/DevTools/DevToolsLogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class DevToolsLogTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyEntryAddedAndClearLog()
{
var domains = session.GetVersionSpecificDomains<V107.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V108.DevToolsSessionDomains>();
ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V107.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
EventHandler<V108.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
{
Assert.That(e.Entry.Text.Contains("404"));
Assert.That(e.Entry.Level == V107.Log.LogEntryLevelValues.Error);
Assert.That(e.Entry.Level == V108.Log.LogEntryLevelValues.Error);
sync.Set();
};

Expand Down
Loading

0 comments on commit 285dace

Please sign in to comment.