Skip to content

Commit 31c8418

Browse files
committed
[dotnet] Add test for Basic Auth using bidi network interception
1 parent 87787e4 commit 31c8418

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

dotnet/test/common/NetworkInterceptionTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,25 @@ public async Task TestCanInterceptNetworkCalls()
3333
Assert.AreEqual("I intercepted you", text);
3434
}
3535
}
36+
37+
[Test]
38+
public async Task TestCanUseAuthorizationHandler()
39+
{
40+
if (driver is IDevTools)
41+
{
42+
INetwork network = driver.Manage().Network;
43+
NetworkAuthenticationHandler handler = new NetworkAuthenticationHandler()
44+
{
45+
UriMatcher = (uri) => uri.PathAndQuery.Contains("basicAuth"),
46+
Credentials = new PasswordCredentials("test", "test")
47+
};
48+
network.AddAuthenticationHandler(handler);
49+
await network.StartMonitoring();
50+
driver.Url = authenticationPage;
51+
string text = driver.FindElement(By.CssSelector("h1")).Text;
52+
await network.StopMonitoring();
53+
Assert.AreEqual("authorized", text);
54+
}
55+
}
3656
}
3757
}

0 commit comments

Comments
 (0)