Skip to content

[🚀 Feature]: Store the Status Code returned by GoToUrl #15844

Open
@sfeng-coveo

Description

@sfeng-coveo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions