How to bypass the authentication popup using Selenium 4

Viewed 515

The website I'm trying to automate has different methods of logging in, depending on the network I'm on. When I'm not on the company's network, it has its login form which is easy enough to automate. When I am the company's network, though, I have to log in via an ADFS authentication popup (this one).

I have tried passing the username and password to the URL, but this doesn't work. Is there a way to bypass this login popup?

Specs:

  • Selenium 4.0.0
  • Chromedriver 96.0.4664.35
  • Chrome 96.0.4664.110
  • openjdk 16.0.2

EDIT: In response to some of the comments, this is how I've tried passing the credentials to the URL:

driver.get(https://username:password@url)

Unfortunately I cannot share the URL due to privacy concerns.

1 Answers

This popup...

BA

...looks like the Basic Authentication popup.

You can bypass the popup embedding the username and password with in the URL as follows:

driver.navigate().to("http://<username>:<password>@your.website.com/basic_auth");

A working example code which opens the URL http://the-internet.herokuapp.com/basic_auth with a valid set of credentials is as follows:

driver.navigate().to("http://admin:admin@the-internet.herokuapp.com/basic_auth");

References

You can find a couple of relevant detailed discussion in:

Related