How we can Handle Popup Authentication using Selenium web driver


While opening few websites Popup Authentication need to be handling to access the website if you are using selenium to automate the website.
Like the below mentioned image authentication popup window looks.

Popup Authentication

Using Selenium Web Driver let’s see “How to Handle Popup Authentication :-

To access some servers companies do have their own proxy settings. A popup window will load & force you to enter user credentials to do login to access the server if you open a server in the Browser. Using selenium script we need to handle the popup before hand accessing the server even while accessing the same server. We couldn’t do further testing if we can’t handle this.
Let’s see in detail to which we could handle this type of authentication pop up.
We all know that selenium web driver is not directly capable of handling the windows based popup and we all know that browser authentication is one time process which generates window based popup to enter username and password to authenticate itself. So the best way is to use “AutoIt” tool which is been used to handle the windows based pop up. It is mainly used when you want to upload any file, download any file and when browsers authentication needs to be done as shown in above image.
First of all user need to download the latest version of “AutoIt” from which will look like this:-

Popup Authentication

You need to install it as you install other software’s and after installation you need to go to “C:\Program Files (x86)\AutoIt3” like this:-

Popup Authentication

Now click to red rectangle “SciTE” folder where u need to click on selected SciTE application so editor will be open where you need to write this code for handling Popup Authentication:-

Popup Authentication

Now user need to click on file option and then click to “save as” option and save it to any location you want. Like I have saved it in D drive in a folder with any name you want to save.

Now user need to go to saved exe location and right click on that exe and click to compile script(x64) so one another exe will be generated as below:-

Popup Authentication Services
After compilation you will see the exe file size of 962kb like this:-

After compilation

Now you can copy the path of the exe and paste it in your selenium script which will run successfully.

selenium script

Written By:- Vijendra Pratap Singh
(Senior Software Tester)
D’selva InfoTech pvt. Ltd, Agra

About the Author