Authentication

This content is for customers only

One common requirement is to authenticate with sites these basic or digest authentication. With Selenium 4, there's an elegant way to do this without needing any additional tooling.

 Let's take a look at this in action. So the next thing I'm going to show off is authentication. And to do this, I'm going to use their well-known websites, the Internet. Which is just here. So we're going to go to this url, then what we're going to do, we're going to click on this thing that requires digest authentication. You'll see here the username and password is admin, so I need to type in admin and admin in order to login.


So this is a really common thing. You see the text congratulations appears. So what we want to be able to do is we want to find the element by linkText Digest Authentication and then we want to wait until the body contains word congratulations.

OK, now, if we were to run this test now, this test would not pass, and the reason for that is we haven't said who we're going to authenticate it. In order to do that, all we need to do is we need to take the driver, we need to register some credentials, and we can either register something that we always use or something that matches against predicate and then uses a set of credentials, username and password and admin. And that's great. So if you run this boom, we go to the Internet hammering. So that's exactly what we wanted to see. 

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}