-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Showing
270 changed files
with
7,350 additions
and
4,806 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,76 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium; | ||
|
||
namespace SeleniumDocs.Bidirectional | ||
{ | ||
[TestClass] | ||
public class BidiApiTest : BaseChromeTest | ||
{ | ||
[TestMethod] | ||
public async Task InterceptNetworkForAuthentication() | ||
{ | ||
var handler = new NetworkAuthenticationHandler() | ||
{ | ||
UriMatcher = _ => true, | ||
Credentials = new PasswordCredentials("admin", "admin") | ||
}; | ||
|
||
INetwork networkInterceptor = driver.Manage().Network; | ||
networkInterceptor.AddAuthenticationHandler(handler); | ||
|
||
await networkInterceptor.StartMonitoring(); | ||
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/basic_auth"); | ||
await networkInterceptor.StopMonitoring(); | ||
|
||
Assert.AreEqual("Congratulations! You must have the proper credentials.", driver.FindElement(By.TagName("p")).Text); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public async Task InterceptNetworkResponse() | ||
{ | ||
var handler = new NetworkResponseHandler() | ||
{ | ||
ResponseMatcher = httpresponse => true, | ||
ResponseTransformer = http => new() | ||
{ | ||
StatusCode = 200, | ||
Body = "Creamy, delicious cheese!" | ||
} | ||
}; | ||
|
||
INetwork networkInterceptor = driver.Manage().Network; | ||
networkInterceptor.AddResponseHandler(handler); | ||
|
||
await networkInterceptor.StartMonitoring(); | ||
driver.Navigate().GoToUrl("https://www.selenium.dev"); | ||
await networkInterceptor.StopMonitoring(); | ||
|
||
StringAssert.Contains(driver.PageSource, "delicious cheese"); | ||
} | ||
|
||
[TestMethod] | ||
public async Task InterceptNetworkRequest() | ||
{ | ||
var handler = new NetworkRequestHandler() | ||
{ | ||
RequestMatcher = httprequest => true, | ||
ResponseSupplier = http => new() | ||
{ | ||
StatusCode = 200, | ||
Body = "Creamy, delicious cheese!" | ||
} | ||
}; | ||
|
||
INetwork networkInterceptor = driver.Manage().Network; | ||
networkInterceptor.AddRequestHandler(handler); | ||
|
||
await networkInterceptor.StartMonitoring(); | ||
driver.Navigate().GoToUrl("https://www.selenium.dev"); | ||
await networkInterceptor.StopMonitoring(); | ||
|
||
StringAssert.Contains(driver.PageSource, "delicious cheese"); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/dotnet/SeleniumDocs/Bidirectional/BidirectionalW3c/BrowsingContextTest.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,10 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace SeleniumDocs.Bidirectional.BidirectionalW3c | ||
{ | ||
[TestClass] | ||
public class BrowsingContextTest : BaseTest | ||
{ | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/dotnet/SeleniumDocs/Bidirectional/BidirectionalW3c/LogTest.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,10 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace SeleniumDocs.Bidirectional.BidirectionalW3c | ||
{ | ||
[TestClass] | ||
public class LogTest : BaseTest | ||
{ | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtoolsTest.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,10 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace SeleniumDocs.Bidirectional | ||
{ | ||
[TestClass] | ||
public class ChomeDevtoolsTest : BaseTest | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.