-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathBrowsingContextTest.Event.UserPrompt.cs
48 lines (34 loc) · 1.6 KB
/
BrowsingContextTest.Event.UserPrompt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.BiDi.Modules.BrowsingContext;
using System;
using System.Threading.Tasks;
namespace SeleniumDocs.BiDi.BrowsingContext;
partial class BrowsingContextTest
{
[TestMethod]
public async Task UserPromptOpenedEvent()
{
TaskCompletionSource<UserPromptOpenedEventArgs> tcs = new();
await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete });
//TODO; THhis event can be a part of context
await bidi.BrowsingContext.OnUserPromptOpenedAsync(tcs.SetResult);
driver.FindElement(By.Id("prompt")).Click();
var userPromptOpenedEventArgs = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
Assert.IsNotNull(userPromptOpenedEventArgs);
Console.WriteLine(userPromptOpenedEventArgs);
}
[TestMethod]
public async Task UserPromptClosedEvent()
{
TaskCompletionSource<UserPromptClosedEventArgs> tcs = new();
await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete });
//TODO; THhis event can be a part of context
await bidi.BrowsingContext.OnUserPromptClosedAsync(tcs.SetResult);
driver.FindElement(By.Id("prompt")).Click();
//await context.HandleUserPromptAsync();
var userPromptClosedEventArgs = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
Assert.IsNotNull(userPromptClosedEventArgs);
Console.WriteLine(userPromptClosedEventArgs);
}
}