Skip to content

Commit

Permalink
[dotnet] Updating DevTools tests to use CDP 114 (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jun 8, 2023
1 parent e55129e commit 3084d2b
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions dotnet/test/common/DevTools/DevToolsNetworkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,34 +332,34 @@ public async Task VerifyResponseReceivedEventAndNetworkDisable()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyWebSocketOperations()
{
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());

EventHandler<V113.Network.WebSocketCreatedEventArgs> webSocketCreatedHandler = (sender, e) =>
EventHandler<V114.Network.WebSocketCreatedEventArgs> webSocketCreatedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
};
domains.Network.WebSocketCreated += webSocketCreatedHandler;

EventHandler<V113.Network.WebSocketFrameReceivedEventArgs> webSocketFrameReceivedHandler = (sender, e) =>
EventHandler<V114.Network.WebSocketFrameReceivedEventArgs> webSocketFrameReceivedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
};
domains.Network.WebSocketFrameReceived += webSocketFrameReceivedHandler;

EventHandler<V113.Network.WebSocketFrameErrorEventArgs>webSocketFrameErrorHandler = (sender, e) =>
EventHandler<V114.Network.WebSocketFrameErrorEventArgs>webSocketFrameErrorHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
};
domains.Network.WebSocketFrameError += webSocketFrameErrorHandler;

EventHandler<V113.Network.WebSocketFrameSentEventArgs> webSocketFrameSentHandler = (sender, e) =>
EventHandler<V114.Network.WebSocketFrameSentEventArgs> webSocketFrameSentHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
};
domains.Network.WebSocketFrameSent += webSocketFrameSentHandler;

EventHandler<V113.Network.WebSocketClosedEventArgs> webSocketClosedHandler = (sender, e) =>
EventHandler<V114.Network.WebSocketClosedEventArgs> webSocketClosedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
};
Expand All @@ -374,13 +374,13 @@ public async Task VerifyWebSocketOperations()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyRequestPostData()
{
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());

string[] requestIds = new string[1];

ManualResetEventSlim requestSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.RequestWillBeSentEventArgs> requestWillBeSentHandler = (sender, e) =>
EventHandler<V114.Network.RequestWillBeSentEventArgs> requestWillBeSentHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
if (string.Compare(e.Request.Method, "post", StringComparison.OrdinalIgnoreCase) == 0)
Expand All @@ -395,7 +395,7 @@ public async Task VerifyRequestPostData()
driver.FindElement(By.XPath("//form/input")).Click();
requestSync.Wait(TimeSpan.FromSeconds(5));

var response = await domains.Network.GetRequestPostData(new V113.Network.GetRequestPostDataCommandSettings()
var response = await domains.Network.GetRequestPostData(new V114.Network.GetRequestPostDataCommandSettings()
{
RequestId = requestIds[0]
});
Expand All @@ -409,9 +409,9 @@ public async Task VerifyRequestPostData()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task ByPassServiceWorker()
{
var domains = session.GetVersionSpecificDomains<V113.DevToolsSessionDomains>();
await domains.Network.Enable(new V113.Network.EnableCommandSettings());
await domains.Network.SetBypassServiceWorker(new V113.Network.SetBypassServiceWorkerCommandSettings()
var domains = session.GetVersionSpecificDomains<V114.DevToolsSessionDomains>();
await domains.Network.Enable(new V114.Network.EnableCommandSettings());
await domains.Network.SetBypassServiceWorker(new V114.Network.SetBypassServiceWorkerCommandSettings()
{
Bypass = true
});
Expand All @@ -423,11 +423,11 @@ await domains.Network.SetBypassServiceWorker(new V113.Network.SetBypassServiceWo
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyEventSourceMessage()
{
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 requestSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.EventSourceMessageReceivedEventArgs> eventSourceMessageReceivedHandler = (sender, e) =>
EventHandler<V114.Network.EventSourceMessageReceivedEventArgs> eventSourceMessageReceivedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
requestSync.Set();
Expand All @@ -445,11 +445,11 @@ public async Task VerifyEventSourceMessage()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifySignedExchangeReceived()
{
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 requestSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.SignedExchangeReceivedEventArgs> signedExchangeReceivedHandler = (sender, e) =>
EventHandler<V114.Network.SignedExchangeReceivedEventArgs> signedExchangeReceivedHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
requestSync.Set();
Expand All @@ -466,11 +466,11 @@ public async Task VerifySignedExchangeReceived()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyResourceChangedPriority()
{
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 requestSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.ResourceChangedPriorityEventArgs> resourceChangedPriorityHandler = (sender, e) =>
EventHandler<V114.Network.ResourceChangedPriorityEventArgs> resourceChangedPriorityHandler = (sender, e) =>
{
Assert.That(e, Is.Not.Null);
requestSync.Set();
Expand All @@ -487,30 +487,30 @@ public async Task VerifyResourceChangedPriority()
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task InterceptRequestAndContinue()
{
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 requestSync = new ManualResetEventSlim(false);
EventHandler<V113.Network.RequestInterceptedEventArgs> requestInterceptedHandler = (async (sender, e) =>
EventHandler<V114.Network.RequestInterceptedEventArgs> requestInterceptedHandler = (async (sender, e) =>
{
await domains.Network.ContinueInterceptedRequest(new V113.Network.ContinueInterceptedRequestCommandSettings()
await domains.Network.ContinueInterceptedRequest(new V114.Network.ContinueInterceptedRequestCommandSettings()
{
InterceptionId = e.InterceptionId
});
requestSync.Set();
});
domains.Network.RequestIntercepted += requestInterceptedHandler;

var pattern = new V113.Network.RequestPattern()
var pattern = new V114.Network.RequestPattern()
{
UrlPattern = "*.css",
ResourceType = V113.Network.ResourceType.Stylesheet,
InterceptionStage = V113.Network.InterceptionStage.HeadersReceived
ResourceType = V114.Network.ResourceType.Stylesheet,
InterceptionStage = V114.Network.InterceptionStage.HeadersReceived
};

await domains.Network.SetRequestInterception(new V113.Network.SetRequestInterceptionCommandSettings()
await domains.Network.SetRequestInterception(new V114.Network.SetRequestInterceptionCommandSettings()
{
Patterns = new V113.Network.RequestPattern[] { pattern }
Patterns = new V114.Network.RequestPattern[] { pattern }
});

driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("js/skins/lightgray/content.min.css");
Expand Down

0 comments on commit 3084d2b

Please sign in to comment.