Skip to content

Commit

Permalink
[dotnet][cdp] Add support CDP 103 and remove CDP 100
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jun 22, 2022
1 parent 0ca6b54 commit 3e8f94c
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 194 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",
"v100",
"v101",
"v102",
"v103",
]

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>()
{
{ 103, typeof(V103.V103Domains) },
{ 102, typeof(V102.V102Domains) },
{ 101, typeof(V101.V101Domains) },
{ 100, typeof(V100.V100Domains) },
{ 85, typeof(V85.V85Domains) }
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V100Domains.cs" company="WebDriver Committers">
// <copyright file="V103Domains.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.V100
namespace OpenQA.Selenium.DevTools.V103
{
/// <summary>
/// Class containing the domain implementation for version 100 of the DevTools Protocol.
/// Class containing the domain implementation for version 103 of the DevTools Protocol.
/// </summary>
public class V100Domains : DevToolsDomains
public class V103Domains : DevToolsDomains
{
private DevToolsSessionDomains domains;

public V100Domains(DevToolsSession session)
public V103Domains(DevToolsSession session)
{
this.domains = new DevToolsSessionDomains(session);
}

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

/// <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 V100Domains(DevToolsSession session)
/// <summary>
/// Gets the object used for manipulating network information in the browser.
/// </summary>
public override DevTools.Network Network => new V100Network(domains.Network, domains.Fetch);
public override DevTools.Network Network => new V103Network(domains.Network, domains.Fetch);

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

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

/// <summary>
/// Gets the object used for manipulating the browser's logs.
/// </summary>
public override DevTools.Log Log => new V100Log(domains.Log);
public override DevTools.Log Log => new V103Log(domains.Log);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V100JavaScript.cs" company="WebDriver Committers">
// <copyright file="V103JavaScript.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.V100.Page;
using OpenQA.Selenium.DevTools.V100.Runtime;
using OpenQA.Selenium.DevTools.V103.Page;
using OpenQA.Selenium.DevTools.V103.Runtime;

namespace OpenQA.Selenium.DevTools.V100
namespace OpenQA.Selenium.DevTools.V103
{
/// <summary>
/// Class containing the JavaScript implementation for version 100 of the DevTools Protocol.
/// Class containing the JavaScript implementation for version 103 of the DevTools Protocol.
/// </summary>
public class V100JavaScript : JavaScript
public class V103JavaScript : JavaScript
{
private RuntimeAdapter runtime;
private PageAdapter page;

/// <summary>
/// Initializes a new instance of the <see cref="V100JavaScript"/> class.
/// Initializes a new instance of the <see cref="V103JavaScript"/> 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 V100JavaScript(RuntimeAdapter runtime, PageAdapter page)
public V103JavaScript(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="V100Log.cs" company="WebDriver Committers">
// <copyright file="V103Log.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.V100.Log;
using OpenQA.Selenium.DevTools.V103.Log;

namespace OpenQA.Selenium.DevTools.V100
namespace OpenQA.Selenium.DevTools.V103
{
/// <summary>
/// Class containing the browser's log as referenced by version 100 of the DevTools Protocol.
/// Class containing the browser's log as referenced by version 103 of the DevTools Protocol.
/// </summary>
public class V100Log : DevTools.Log
public class V103Log : DevTools.Log
{
private LogAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V100Log"/> class.
/// Initializes a new instance of the <see cref="V103Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
public V100Log(LogAdapter adapter)
public V103Log(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="V100Network.cs" company="WebDriver Committers">
// <copyright file="V103Network.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.V100.Fetch;
using OpenQA.Selenium.DevTools.V100.Network;
using OpenQA.Selenium.DevTools.V103.Fetch;
using OpenQA.Selenium.DevTools.V103.Network;

namespace OpenQA.Selenium.DevTools.V100
namespace OpenQA.Selenium.DevTools.V103
{
/// <summary>
/// Class providing functionality for manipulating network calls using version 100 of the DevTools Protocol
/// Class providing functionality for manipulating network calls using version 103 of the DevTools Protocol
/// </summary>
public class V100Network : DevTools.Network
public class V103Network : DevTools.Network
{
private FetchAdapter fetch;
private NetworkAdapter network;

/// <summary>
/// Initializes a new instance of the <see cref="V100Network"/> class.
/// Initializes a new instance of the <see cref="V103Network"/> class.
/// </summary>
/// <param name="network">The adapter for the Network domain.</param>
/// <param name="fetch">The adapter for the Fetch domain.</param>
public V100Network(NetworkAdapter network, FetchAdapter fetch)
public V103Network(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.V100.Fetch.EnableCommandSettings()
await fetch.Enable(new OpenQA.Selenium.DevTools.V103.Fetch.EnableCommandSettings()
{
Patterns = new OpenQA.Selenium.DevTools.V100.Fetch.RequestPattern[]
Patterns = new OpenQA.Selenium.DevTools.V103.Fetch.RequestPattern[]
{
new OpenQA.Selenium.DevTools.V100.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request },
new OpenQA.Selenium.DevTools.V100.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response }
new OpenQA.Selenium.DevTools.V103.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request },
new OpenQA.Selenium.DevTools.V103.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 V100.Fetch.AuthChallengeResponse()
AuthChallengeResponse = new V103.Fetch.AuthChallengeResponse()
{
Response = V100.Fetch.AuthChallengeResponseResponseValues.ProvideCredentials,
Response = V103.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.V100.Fetch.AuthChallengeResponse()
AuthChallengeResponse = new OpenQA.Selenium.DevTools.V103.Fetch.AuthChallengeResponse()
{
Response = V100.Fetch.AuthChallengeResponseResponseValues.CancelAuth
Response = V103.Fetch.AuthChallengeResponseResponseValues.CancelAuth
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V100Target.cs" company="WebDriver Committers">
// <copyright file="V103Target.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.V100.Target;
using OpenQA.Selenium.DevTools.V103.Target;

namespace OpenQA.Selenium.DevTools.V100
namespace OpenQA.Selenium.DevTools.V103
{
/// <summary>
/// Class providing functionality for manipulating targets for version 100 of the DevTools Protocol
/// Class providing functionality for manipulating targets for version 103 of the DevTools Protocol
/// </summary>
public class V100Target : DevTools.Target
public class V103Target : DevTools.Target
{
private TargetAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V100Target"/> class.
/// Initializes a new instance of the <see cref="V103Target"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Target domain.</param>
public V100Target(TargetAdapter adapter)
public V103Target(TargetAdapter adapter)
{
this.adapter = adapter;
adapter.DetachedFromTarget += OnDetachedFromTarget;
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\v100\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 100
pushd "%1..\..\.."
bazel build //dotnet/src/webdriver/cdp:generate-v100
popd
)

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

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v103\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 103
pushd "%1..\..\.."
bazel build //dotnet/src/webdriver/cdp:generate-v103
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/v100/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 100"
bazel build //dotnet/src/webdriver/cdp:generate-v100
fi

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

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v103/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 103"
bazel build //dotnet/src/webdriver/cdp:generate-v103
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<V102.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V103.DevToolsSessionDomains>();
string consoleMessage = "Hello Selenium";

ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V102.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
EventHandler<V103.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 @@ -18,12 +18,12 @@ public class DevToolsLogTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyEntryAddedAndClearLog()
{
var domains = session.GetVersionSpecificDomains<V102.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V103.DevToolsSessionDomains>();
ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V102.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
EventHandler<V103.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
{
Assert.That(e.Entry.Text.Contains("404"));
Assert.That(e.Entry.Level == V102.Log.LogEntryLevelValues.Error);
Assert.That(e.Entry.Level == V103.Log.LogEntryLevelValues.Error);
sync.Set();
};

Expand Down
Loading

0 comments on commit 3e8f94c

Please sign in to comment.