Description
Description
Consider the following C#/.NET code where I use ChromeDriver
and add a basic authentication to retrieve a page content:
var driver = new ChromeDriver();
driver.Manage().Network.AddAuthenticationHandler(
new NetworkAuthenticationHandler
{
UriMatcher = _ => true,
Credentials = new PasswordCredentials("someUsername", "somePassword"),
}
);
driver.Navigate().GoToUrl("https://someurlthatrequiresauth.com/");
Naturally, the authentication may succeed or fails depending on whether the credentials match, and I would like a reliable way to know that, for example by accessing a StatusCode
attribute. To my knowledge, the driver itself doesn't seem to have different behavior in both cases other than driver.PageSource
content would be different.
Have you considered any alternatives or workarounds?
If I was using something like HttpClient
, I can easily verify the response StatusCode
for this, but I really want to avoid sending double the call for each url I have to authenticate just to know if it works or not. I haven't found anything similar on ChromDriver
's properties. Verifying driver.PageSource
content is unreliable since the source content can be anything.