-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d92ca5
commit 34a0c78
Showing
7 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...tnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.BrowsingContextCreatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task BrowsingContextCreatedEvent() | ||
{ | ||
await using var bidi = await driver.AsBidirectionalAsync(); | ||
|
||
BrowsingContextInfo info = null; | ||
|
||
await bidi.OnBrowsingContextCreatedAsync(e => info = e); | ||
|
||
driver.SwitchTo().NewWindow(OpenQA.Selenium.WindowType.Window); | ||
|
||
Assert.IsNotNull(info); | ||
Console.WriteLine(info); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...et/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.BrowsingContextDestroyedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task BrowsingContextDestroyedEvent() | ||
{ | ||
await using var bidi = await driver.AsBidirectionalAsync(); | ||
|
||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
TaskCompletionSource<BrowsingContextInfo> tcs = new(); | ||
|
||
await bidi.OnBrowsingContextDestroyedAsync(tcs.SetResult); | ||
|
||
await browsingContext.CloseAsync(); | ||
|
||
var browsingContextInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); | ||
|
||
Assert.IsNotNull(browsingContextInfo); | ||
Assert.AreEqual(browsingContext, browsingContextInfo.Context); | ||
Console.WriteLine(browsingContextInfo); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...otnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.BrowsingContextLoadedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task BrowsingContextLoadedEvent() | ||
{ | ||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
TaskCompletionSource<NavigationInfo> tcs = new(); | ||
|
||
await browsingContext.OnLoadAsync(tcs.SetResult); | ||
|
||
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); | ||
|
||
var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); | ||
|
||
Assert.IsNotNull(navigationInfo); | ||
Console.WriteLine(navigationInfo); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...les/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.DomContentLoadedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task DomContentLoadedEvent() | ||
{ | ||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
TaskCompletionSource<NavigationInfo> tcs = new(); | ||
|
||
await browsingContext.OnDomContentLoadedAsync(tcs.SetResult); | ||
|
||
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); | ||
|
||
var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); | ||
|
||
Assert.IsNotNull(navigationInfo); | ||
Console.WriteLine(navigationInfo); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...es/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.FragmentNavigatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task FragmentNavigatedEvent() | ||
{ | ||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
TaskCompletionSource<NavigationInfo> tcs = new(); | ||
|
||
await browsingContext.OnFragmentNavigatedAsync(tcs.SetResult); | ||
|
||
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", new() { Wait = ReadinessState.Complete }); | ||
|
||
var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); | ||
|
||
Assert.IsNotNull(navigationInfo); | ||
Console.WriteLine(navigationInfo); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...es/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.NavigationStartedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task NavigationStartedEvent() | ||
{ | ||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
NavigationInfo info = null; | ||
|
||
await browsingContext.OnNavigationStartedAsync(e => info = e); | ||
|
||
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); | ||
|
||
Assert.IsNotNull(info); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.UserPromptEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.BiDi; | ||
using OpenQA.Selenium.BiDi.Modules.BrowsingContext; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SeleniumDocs.BiDi.BrowsingContext; | ||
|
||
partial class BrowsingContextTest | ||
{ | ||
[TestMethod] | ||
public async Task UserPromptOpenedEvent() | ||
{ | ||
await using var bidi = await driver.AsBidirectionalAsync(); | ||
|
||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
TaskCompletionSource<UserPromptOpenedEventArgs> tcs = new(); | ||
|
||
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); | ||
|
||
await bidi.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() | ||
{ | ||
await using var bidi = await driver.AsBidirectionalAsync(); | ||
|
||
var browsingContext = await driver.AsBidirectionalContextAsync(); | ||
|
||
TaskCompletionSource<UserPromptClosedEventArgs> tcs = new(); | ||
|
||
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); | ||
|
||
await bidi.OnUserPromptClosedAsync(tcs.SetResult); | ||
|
||
driver.FindElement(By.Id("prompt")).Click(); | ||
|
||
//await browsingContext.HandleUserPromptAsync(); | ||
|
||
var userPromptClosedEventArgs = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); | ||
|
||
Assert.IsNotNull(userPromptClosedEventArgs); | ||
Console.WriteLine(userPromptClosedEventArgs); | ||
} | ||
} |