Skip to content

Commit

Permalink
[dotnet][cdp] implement get targets better
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 29, 2022
1 parent aa5dfd6 commit 9480f0d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class Target
/// contains the list of <see cref="TargetInfo"/> objects describing the
/// targets available for this session.
/// </returns>
public abstract Task<ReadOnlyCollection<TargetInfo>> GetTargets();
public abstract Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null);

/// <summary>
/// Asynchronously attaches to a target.
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v105/V105Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public V105Target(TargetAdapter adapter)
/// contains the list of <see cref="TargetInfo"/> objects describing the
/// targets available for this session.
/// </returns>
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets()
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null)
{
List<TargetInfo> targets = new List<TargetInfo>();
var response = await adapter.GetTargets();
Expand Down
8 changes: 6 additions & 2 deletions dotnet/src/webdriver/DevTools/v106/V106Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ public V106Target(TargetAdapter adapter)
/// contains the list of <see cref="TargetInfo"/> objects describing the
/// targets available for this session.
/// </returns>
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets()
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null)

{
List<TargetInfo> targets = new List<TargetInfo>();
var response = await adapter.GetTargets(new GetTargetsCommandSettings());
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
8 changes: 6 additions & 2 deletions dotnet/src/webdriver/DevTools/v107/V107Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ public V107Target(TargetAdapter adapter)
/// contains the list of <see cref="TargetInfo"/> objects describing the
/// targets available for this session.
/// </returns>
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets()
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null)

{
List<TargetInfo> targets = new List<TargetInfo>();
var response = await adapter.GetTargets(new GetTargetsCommandSettings());
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
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v85/V85Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public V85Target(TargetAdapter adapter)
/// contains the list of <see cref="TargetInfo"/> objects describing the
/// targets available for this session.
/// </returns>
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets()
public override async Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null)
{
List<TargetInfo> targets = new List<TargetInfo>();
var response = await adapter.GetTargets();
Expand Down
8 changes: 3 additions & 5 deletions dotnet/test/common/DevTools/DevToolsTargetTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium.DevTools.V107.Target;
using OpenQA.Selenium.Environment;

namespace OpenQA.Selenium.DevTools
Expand All @@ -22,7 +20,7 @@ public async Task GetTargetActivateAndAttach()
{
var domains = session.GetVersionSpecificDomains<V107.DevToolsSessionDomains>();
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("devToolsConsoleTest.html");
var response = await domains.Target.GetTargets();
var response = await domains.Target.GetTargets(new GetTargetsCommandSettings());
V107.Target.TargetInfo[] allTargets = response.TargetInfos;
foreach (V107.Target.TargetInfo targetInfo in allTargets)
{
Expand Down Expand Up @@ -62,7 +60,7 @@ public async Task GetTargetAndSendMessageToTarget()
ValidateMessage(e);
sync.Set();
};
var targetsResponse = await domains.Target.GetTargets();
var targetsResponse = await domains.Target.GetTargets(new GetTargetsCommandSettings());
allTargets = targetsResponse.TargetInfos;
ValidateTargetsInfos(allTargets);
ValidateTarget(allTargets[0]);
Expand Down

0 comments on commit 9480f0d

Please sign in to comment.