Skip to content

Commit

Permalink
[dotnet] Updating DevTools tests to use CDP 114
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jun 7, 2023
1 parent 85a0c67 commit e45195e
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 100 deletions.
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<V113.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
string consoleMessage = "Hello Selenium";

ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V113.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
EventHandler<V114.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<V113.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V113.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
EventHandler<V114.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
{
Assert.That(e.Entry.Text.Contains("404"));
Assert.That(e.Entry.Level == V113.Log.LogEntryLevelValues.Error);
Assert.That(e.Entry.Level == V114.Log.LogEntryLevelValues.Error);
sync.Set();
};

Expand Down
80 changes: 40 additions & 40 deletions dotnet/test/common/DevTools/DevToolsNetworkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class DevToolsNetworkTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public void GetSetDeleteAndClearAllCookies()
{
//var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
//await domains.Network.Enable(new V113.Network.EnableCommandSettings());
//var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
//await domains.Network.Enable(new V114.Network.EnableCommandSettings());

//var allCookieResponse = await domains.Network.GetAllCookies();
//ReadOnlyCollection<Cookie> seleniumCookies = allCookieResponse.Cookies.ToSeleniumCookies();
Expand All @@ -36,11 +36,11 @@ public void GetSetDeleteAndClearAllCookies()
//seleniumCookies = allCookieResponse.Cookies.ToSeleniumCookies();
//Assert.That(seleniumCookies.Count == 1);

//var cookieResponse = await domains.Network.GetCookies(new V113.Network.GetCookiesCommandSettings());
//var cookieResponse = await domains.Network.GetCookies(new V114.Network.GetCookiesCommandSettings());
//seleniumCookies = cookieResponse.Cookies.ToSeleniumCookies();
//Assert.That(seleniumCookies.Count == 0);

//await domains.Network.DeleteCookies(new V113.Network.DeleteCookiesCommandSettings()
//await domains.Network.DeleteCookies(new V114.Network.DeleteCookiesCommandSettings()
//{
// Name = "name",
// Domain = EnvironmentManager.Instance.UrlBuilder.HostName,
Expand All @@ -67,34 +67,34 @@ public void GetSetDeleteAndClearAllCookies()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task SendRequestWithUrlFiltersAndExtraHeadersAndVerifyRequests()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
await domains.Network.Enable(new V113.Network.EnableCommandSettings());
await domains.Network.SetBlockedURLs(new V113.Network.SetBlockedURLsCommandSettings()
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
await domains.Network.Enable(new V114.Network.EnableCommandSettings());
await domains.Network.SetBlockedURLs(new V114.Network.SetBlockedURLsCommandSettings()
{
Urls = new string[] { "*://*/*.css" }
});

var additionalHeaders = new V113.Network.Headers();
var additionalHeaders = new V114.Network.Headers();
additionalHeaders.Add("headerName", "headerValue");
await domains.Network.SetExtraHTTPHeaders(new V113.Network.SetExtraHTTPHeadersCommandSettings()
await domains.Network.SetExtraHTTPHeaders(new V114.Network.SetExtraHTTPHeadersCommandSettings()
{
Headers = additionalHeaders
});

ManualResetEventSlim loadingFailedSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.LoadingFailedEventArgs> loadingFailedHandler = (sender, e) =>
EventHandler<V114.Network.LoadingFailedEventArgs> loadingFailedHandler = (sender, e) =>
{
if (e.Type == V113.Network.ResourceType.Stylesheet)
if (e.Type == V114.Network.ResourceType.Stylesheet)
{
Assert.That(e.BlockedReason == V113.Network.BlockedReason.Inspector);
Assert.That(e.BlockedReason == V114.Network.BlockedReason.Inspector);
}
loadingFailedSync.Set();
};
domains.Network.LoadingFailed += loadingFailedHandler;

ManualResetEventSlim requestSentSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.RequestWillBeSentEventArgs> requestWillBeSentHandler = (sender, e) =>
EventHandler<V114.Network.RequestWillBeSentEventArgs> requestWillBeSentHandler = (sender, e) =>
{
Assert.That(e.Request.Headers.ContainsKey("headerName"));
Assert.That(e.Request.Headers["headerName"] == "headerValue");
Expand All @@ -103,7 +103,7 @@ await domains.Network.SetExtraHTTPHeaders(new V113.Network.SetExtraHTTPHeadersCo
domains.Network.RequestWillBeSent += requestWillBeSentHandler;

ManualResetEventSlim dataSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.DataReceivedEventArgs> dataReceivedHandler = (sender, e) =>
EventHandler<V114.Network.DataReceivedEventArgs> dataReceivedHandler = (sender, e) =>
{
Assert.That(e.RequestId, Is.Not.Null);
dataSync.Set();
Expand All @@ -122,23 +122,23 @@ await domains.Network.SetExtraHTTPHeaders(new V113.Network.SetExtraHTTPHeadersCo
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task EmulateNetworkConditionOffline()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
await domains.Network.Enable(new V113.Network.EnableCommandSettings()
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
await domains.Network.Enable(new V114.Network.EnableCommandSettings()
{
MaxTotalBufferSize = 100000000
});

await domains.Network.EmulateNetworkConditions(new V113.Network.EmulateNetworkConditionsCommandSettings()
await domains.Network.EmulateNetworkConditions(new V114.Network.EmulateNetworkConditionsCommandSettings()
{
Offline = true,
Latency = 100,
DownloadThroughput = 1000,
UploadThroughput = 2000,
ConnectionType = V113.Network.ConnectionType.Cellular3g
ConnectionType = V114.Network.ConnectionType.Cellular3g
});

ManualResetEventSlim loadingFailedSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.LoadingFailedEventArgs> loadingFailedHandler = (sender, e) =>
EventHandler<V114.Network.LoadingFailedEventArgs> loadingFailedHandler = (sender, e) =>
{
Assert.That(e.ErrorText, Is.EqualTo("net::ERR_INTERNET_DISCONNECTED"));
loadingFailedSync.Set();
Expand All @@ -164,16 +164,16 @@ await domains.Network.EmulateNetworkConditions(new V113.Network.EmulateNetworkCo
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyRequestReceivedFromCacheAndResponseBody()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
string[] requestIdFromCache = new string[1];

await domains.Network.Enable(new V113.Network.EnableCommandSettings()
await domains.Network.Enable(new V114.Network.EnableCommandSettings()
{
MaxResourceBufferSize = 100000000
});

ManualResetEventSlim servedFromCacheSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.RequestServedFromCacheEventArgs> requestServedFromCacheHandler = (sender, e) =>
EventHandler<V114.Network.RequestServedFromCacheEventArgs> requestServedFromCacheHandler = (sender, e) =>
{
Assert.That(e.RequestId, Is.Not.Null);
requestIdFromCache[0] = e.RequestId;
Expand All @@ -182,7 +182,7 @@ await domains.Network.Enable(new V113.Network.EnableCommandSettings()
domains.Network.RequestServedFromCache += requestServedFromCacheHandler;

ManualResetEventSlim loadingFinishedSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.LoadingFinishedEventArgs> loadingFinishedHandler = (sender, e) =>
EventHandler<V114.Network.LoadingFinishedEventArgs> loadingFinishedHandler = (sender, e) =>
{
Assert.That(e.RequestId, Is.Not.Null);
loadingFinishedSync.Set();
Expand All @@ -194,7 +194,7 @@ await domains.Network.Enable(new V113.Network.EnableCommandSettings()
loadingFinishedSync.Wait(TimeSpan.FromSeconds(5));
servedFromCacheSync.Wait(TimeSpan.FromSeconds(5));

var responseBody = await domains.Network.GetResponseBody(new V113.Network.GetResponseBodyCommandSettings()
var responseBody = await domains.Network.GetResponseBody(new V114.Network.GetResponseBodyCommandSettings()
{
RequestId = requestIdFromCache[0]
});
Expand All @@ -209,16 +209,16 @@ await domains.Network.Enable(new V113.Network.EnableCommandSettings()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifySearchInResponseBody()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
string[] requestIds = new string[1];

await domains.Network.Enable(new V113.Network.EnableCommandSettings()
await domains.Network.Enable(new V114.Network.EnableCommandSettings()
{
MaxResourceBufferSize = 100000000
});

ManualResetEventSlim responseSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.ResponseReceivedEventArgs> responseReceivedHandler = (sender, e) =>
EventHandler<V114.Network.ResponseReceivedEventArgs> responseReceivedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
requestIds[0] = e.RequestId;
Expand All @@ -229,7 +229,7 @@ await domains.Network.Enable(new V113.Network.EnableCommandSettings()
driver.Url = simpleTestPage;
responseSync.Wait(TimeSpan.FromSeconds(5));

var searchResponse = await domains.Network.SearchInResponseBody(new V113.Network.SearchInResponseBodyCommandSettings()
var searchResponse = await domains.Network.SearchInResponseBody(new V114.Network.SearchInResponseBodyCommandSettings()
{
RequestId = requestIds[0],
Query = "/",
Expand All @@ -244,14 +244,14 @@ await domains.Network.Enable(new V113.Network.EnableCommandSettings()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyCacheDisabledAndClearCache()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
await domains.Network.Enable(new V113.Network.EnableCommandSettings()
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
await domains.Network.Enable(new V114.Network.EnableCommandSettings()
{
MaxPostDataSize = 100000000
});

ManualResetEventSlim responseSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.ResponseReceivedEventArgs> responseReceivedHandler = (sender, e) =>
EventHandler<V114.Network.ResponseReceivedEventArgs> responseReceivedHandler = (sender, e) =>
{
Assert.That(e.Response.FromDiskCache, Is.False);
responseSync.Set();
Expand All @@ -261,7 +261,7 @@ await domains.Network.Enable(new V113.Network.EnableCommandSettings()
driver.Url = simpleTestPage;
responseSync.Wait(TimeSpan.FromSeconds(5));

await domains.Network.SetCacheDisabled(new V113.Network.SetCacheDisabledCommandSettings()
await domains.Network.SetCacheDisabled(new V114.Network.SetCacheDisabledCommandSettings()
{
CacheDisabled = true
});
Expand All @@ -277,16 +277,16 @@ await domains.Network.SetCacheDisabled(new V113.Network.SetCacheDisabledCommandS
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyCertificatesAndOverrideUserAgent()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
await domains.Network.Enable(new V113.Network.EnableCommandSettings());
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
await domains.Network.Enable(new V114.Network.EnableCommandSettings());

await domains.Network.SetUserAgentOverride(new V113.Network.SetUserAgentOverrideCommandSettings()
await domains.Network.SetUserAgentOverride(new V114.Network.SetUserAgentOverrideCommandSettings()
{
UserAgent = "userAgent"
});

ManualResetEventSlim requestSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.RequestWillBeSentEventArgs> requestWillBeSentHandler = (sender, e) =>
EventHandler<V114.Network.RequestWillBeSentEventArgs> requestWillBeSentHandler = (sender, e) =>
{
Assert.That(e.Request.Headers["User-Agent"], Is.EqualTo("userAgent"));
requestSync.Set();
Expand All @@ -297,7 +297,7 @@ await domains.Network.SetUserAgentOverride(new V113.Network.SetUserAgentOverride
driver.Url = origin;
requestSync.Wait(TimeSpan.FromSeconds(5));

var result = await domains.Network.GetCertificate(new V113.Network.GetCertificateCommandSettings()
var result = await domains.Network.GetCertificate(new V114.Network.GetCertificateCommandSettings()
{
Origin = origin
});
Expand All @@ -311,10 +311,10 @@ await domains.Network.SetUserAgentOverride(new V113.Network.SetUserAgentOverride
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyResponseReceivedEventAndNetworkDisable()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
await domains.Network.Enable(new V113.Network.EnableCommandSettings());
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
await domains.Network.Enable(new V114.Network.EnableCommandSettings());
ManualResetEventSlim responseSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.ResponseReceivedEventArgs> responseReceivedHandler = (sender, e) =>
EventHandler<V114.Network.ResponseReceivedEventArgs> responseReceivedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
responseSync.Set();
Expand Down
Loading

0 comments on commit e45195e

Please sign in to comment.