Handle Authentication Popup using Selenium Library in Robot Framework

Hi,

I just started automation using Robot Framework with Selenium Library. I was able to run a sample test in our application. The issue I am seeing is the authentication popup.

Could some one please help me how to handle this authentication popup using Selenium Library? Also this popup does not come all the times. How to check if that pop up is there or not?

Any help is much appreciated.

Hi Ravi,

Depends what sort of popup you are getting? If it’s a browser popup you can search the Selenium Library help for “alert” and find the keywords for dealing with those, you might also be able to prevent it from popping up by putting the username and password in the url (something like https://user:pass@your.application.test/ or https://your.application.test/loginpage?username=user&password=pass )

if it’s just a html popup then Input Text and Input Password should be all you need

Dave.

Hi Dave,

Thankyou for your reply. Below is the popup that I am seeing (for security reasons I whitened out the URL) and this is not a browser popup (I think this is a native popup because I am not able to inspect it). I want to try by passing Username and password in the URL but this only comes sometimes and not sure when. Could you please help me how to handle this with Selenium Library in Robot Framework?

Regards,Ravi

Hi Ravi,

Actually because you can’t inspect it, it probably is browser popup, because if you could inspect it it would be a html popup.

What you didn’t mention before was that it’s no the AUT that is requesting authentication but rather the proxy server.

One thing that concerns me is your comment :

What I suggest you do is set up a simple robot file with a single test similar to the one below (guessing that you are using Chrome):

*** Settings ***
Library		SeleniumLibrary

*** Keywords ***
Open Admin Page
	Open Browser	about:blank		Chrome
	Go To		https://your.application.page
	Wait Until Page Contains		<Some text you expect on the first page>

The first thing you want to confirm is if this test always fails with the proxy dialog you showed or only sometimes?

If this dialog only appears sometimes, that would indicate that you have multiple proxy servers in your environment and they are not configured consistently, so this should be raised with your IT support team to ensure all the proxy servers are correctly configured, once this has happened you should be getting either

  1. always now getting this dialog or
  2. never getting this dialog

Once you are at a point where you are getting a consistent behaviour, if you still need to authenticate with the proxy try changing the test case to:

*** Settings ***
Library		SeleniumLibrary

*** Keywords ***
Open Admin Page
	Open Browser	about:blank		Chrome
	Go To		https://<proxy username>:<proxy password>@your.application.page
	Wait Until Page Contains		<Some text you expect on the first page>

Also note if the proxy user name needs the windows domain name in the format of <domain>\<username> don’t forget to escape the \, i.e.<domain>\\<username>

Some additional details about selenium and proxy authentication that I found (this is not using Robot Framework)

Dave.

Thankyou Dave, apologize for the delay. I will try out all the options above. I tried Browser library as well and noticed that could be handled in Browser Library.

If this is HTTP Authentication, as seen in this web testing demo site or as shown in the link Dave has shared above then the underlying Selenium 4 has added functionality to handle this. The SeleniumLibrary (the Robot Framework library connecting Robot Framework to Selenium) can add this. The SeleniumLibrary core team has a survey out asking which of the new Selenum 4 features due users want to see prioritized including authentication.

Thankyou Ed. I will check it out. But for now I’ve to browser library and dont have this issue :slightly_smiling_face: