[フレーム]

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Advance Selenium / Handle Windows Authentication Popup using Selenium Webdriver

Handle Windows Authentication Popup using Selenium Webdriver

by 53 Comments

[画像:Handle Windows Authentication using Selenium Webdriver]

Handle Authentication Popup using Selenium Webdriver

Hello, people welcome back to Selenium Tutorial, in this post we will see how to handle windows authentication popup using Selenium webdriver.

Why we are getting Authentication window

Each company having some proxy setting for the specific application so while running script using Selenium you will get this authentication window which asks for Username and password so until we don’t handle this you cannot navigate to parent window.

Example- I have found this URL where actually u can see this pop-up.

https://www.engprod-charter.net/

How to Handle Authentication using Selenium

I think its time to handle this Authentication so now there are two ways for this.

Refer complete video for the same-

[フレーム]

First approach- Handle Windows Authentication popup using Selenium Webdriver

You can provide credentials in URL itself it means we will add username and password in URL so while running script it will bypass the same.

Syntax

http://username:password@url

Example :

http://mukeshotwani:password1234@www.xyz.com

Second approach: Handle Windows Authentication popup using Selenium Webdriver

We can use AutoIT again to handle this authentication window for this Please check whether you have AutoIT installed or not. If not then please download from here

1) Open the Url ENGPROD on which the authentication is required and open the AutoIt Window Info tool to get the name of the class and the text of the authentication window.

Handle Windows Authentication popup using Selenium Webdriver

2) drag the ‘Finder Toolbox to the object in which you are interested and it displays you the information.

Handle Windows Authentication popup using Selenium Webdriver 3) If you download the full version of Scite4AutoIt3 and look for the Au3Recorder in the Tools menu.

Open the Script Editor window, save the blank file with ‘.au3′ extension and then go to Tools > AU3Recorder or Alt + F6 on AutoIt Script Editor.

A window will open for recording. Let us record the steps to send the username & password to the authentication window, for that please activate the Recorder by Tools >AU3Recorder or Alt + F6 on AutoIt Script Editor.

Handle Windows Authentication using Selenium Webdriver
4) Top left signal says that the recording is on. Now type the username and password and do not use the mouse to click on any field, simply use keyboard’s tab button to do the thing.

Handle Windows Authentication using Selenium Webdriver

5) Once you did with your recording, your code will look like this.

Handle Windows Authentication using Selenium Webdriver
6) Now save the above script, if in case you have not saved the name earlier, please save it in .au3 format.

The next step is to convert it into the .exe format. For that, you need to do a right click on the .au3 file and select "Compile Script".

Handle Windows Authentication using Selenium Webdriver
Note: Make sure that you select ‘Compile Script’ as per your machine configuration. Select normal version if you are on 32 bits, and select x64 or x86 if you are on 64 bits.
7) Once you did with the compiling, it will create the ‘.exe’ file with the same name under the same folder and that ‘.exe’ the file will be called in the Selenium Test Script by using the following script:

Handle Windows Authentication using Selenium Webdriver

Reader Interactions

Comments

  1. Yoga says

    I need to handle this in firefox and also I need to do parallel execution (multi threads)..Is this work in multi threads?No means how to handle in multi threads execution?

  2. Pon Surya Prakash I says

    Hi Mukesh,

    In our application, lets say “abc.com”, authentication popup comes with different server URL (like “xyz.com”). In that case how can I proceed. With Selenium 4, I even tried, But I am unable to do it. Could you give your thoughts on this..

    Thanks,
    Pon Surya Prakash I

  3. Divya C M says

    Hi Mukesh Sir,

    I have created a autoit script for authentication in windows pop up. Selenium code invoke the autoit script using “Runtime.getRuntime().exec(“autoitscript”) ”

    But once the script is invoked it keeps on running at the back ground, I.e again authentication pop up is loading.

    How to stop it once the autoit script completes its action.

    Using Chrome Version 90, Firefox Version 93 and selenium 3.141

    AutoIT script

    WinActivate(“Mozilla Firefox”)
    Send(“Username”)
    Send(“{TAB}”)
    Send(“Password”)
    Send(“{ENTER}”)
    Sleep(3000)

    Thank you,
    Divya

  4. Muthukumar says

    Hi ji,

    I saw your selenium Live Project video and i have tried ,one more help we need part 2,part 3, live video …it’s very help for us .so could you pls do it?

    Screen shot, Cofing file ,using Xml,TestNG coverd Live video ji Pls .

  5. sadasiba panda says

    Hi Mukesh,

    I have tried 1st approach as in my application we are using “domainname/username” and “Password”.So 1st approach did not work for me.Then i tried 2nd approach whatever you mentioned in video But i am not able handle the authentication pop up.please help me on this.

  6. Dhananjay says

    Hello Mukesh,
    https://username:password@URL can handle single authentication pop up, if there are more than one auth pop up, can we construct a URL for the same ? if yes, could you please help me out. I am looking for solution which can handle a auth pop up for both MAC and Windows.

  7. Sujata says

    Hi Mukesh
    I am a Mac User and AutoIT does not work with MAC.
    Can you pls suggest, I need to automate the same authentication window but using MAC

  8. Priyanka says

    Hi Mukesh,
    I am trying to handle Download pop up on my Mac OS system but I don’t know which tool to use coz Auto IT doesn’t work with MacOS .I already know how to work with Robot API,but i want to know some AutoIT equivalent tool for Mac OS and also how to work on the tool.Can you please help me here. Thanks 🙂

  9. Ram says

    Hello Mukesh,
    I am new in Selenium Web Driver,

    can you tell me how to handle Dynamic web tables using POM.

    I have Web Table n number of rows and n number of columns ,But i need select a particular based as column 1 and i need to click columns 5.

  10. Madhur Bharadwaj says

    HI this is the very good way to handle the Authentication Alert , it was working fine for me but now i am getting below error about this please help:

    org.openqa.selenium.UnhandledAlertException: Modal dialog present:
    Build info: version: ‘2.44.0’, revision: ’76d78cf’, time: ‘2014年10月23日 20:03:00’
    System info: host: ‘DS-6CF049FD194D’, ip: ‘10.144.49.187’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.8.0_77’
    Driver info: org.openqa.selenium.ie.InternetExplorerDriver
    Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:12885/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
    Session ID: 60008b87-c5f2-4695-b6d9-92bb0b26e7ca

  11. Abhishek Gajra says

    Hi Mukesh,
    I tried the method you specified. I am working with selenium (Eclipse Juno) and trying to write the script for auto login on the pop up just like above but in chrome. But it is not working for me. I have done exactly what you have done. Tried putting the path after and before I am opening the browser but no change. It is not filling the field with the required credentials.

    I also tried looking for the Auto Recorder but I could not find it at all.

    Could you please help,

  12. selva says

    We are in the situation that we don’t know when the authentication proxy pop-up shows up but we need to close it by clicking on cancel/ok-button. At the same time, we can not call AutoIt script for every get method of firefox driver because we have 100 of test cases. What we are expecting is, something like we need to run AutoIt script when selenium automation starts and the script should be always running and if pop up rise then the script has to close it and it has to go back running status instead stop. I am waiting for answer,as you mentioned you would post answer for this

  13. Arunkumar Ramakrishnan says

    Hi Mukesh,

    Thanks for all your videos and tutorials it was really helpful, i just implemented the auto it script authentication window as per the tutorial it was worked well for me, same like akashsuthwal question i want to use multiple times in my script still there is no answer i have found please help me to proceed further

    Thanks advance.
    Arun

  14. Vishy says

    Hi Mukesh , this is awesome blog, can u plz share the way to parameterize the input for Auto IT tool so that it accepts while Authenticating the pop up, you told you will post it in a weeks time while replying to Akash, i am eagerly waiting 4 the same.

  15. Abhilash Pethambaran says

    HI Mukesh,

    Thank you for your effort to make this happen. I have a task to handle this authentication pop up using selenium webdriver not just in windows but in Linux and mac os. I don’t think AutoIt will fit for the rest but windows. Could you guide me with some help so that I could complete. I got another option rather than this which is by using Sikuli IDE. I am completely new to this and I have already crossed the deadline.
    Could you please help me achieve it.
    Looking forward to hear from you.

    Thanks
    Abhi

  16. akashsuthwal says

    i want to login with 20-30 different user’s credentials , so for that do i have to write 20-30 autoit scripts ???
    is there any option that Autoit script took parameters from an excel file ?

    • Uday says

      Same issue with me also, I have used below script in Autoit,but not taking passed values in user name and password fields and also its not displaying any error in console.

      WinWaitActive(“Authentication Required”)
      Send(“uday”)
      Send(“{TAB}”)
      send(“sarikonda”)
      Send(“{ENTER}”)

      and passing below mentioned code in class.

      Runtime.getRuntime().exec(“C:\\Users\\UDAY\\Desktop\\autoit.exe”);

      can you please help me..

      together a head,
      Uday Reddy.S

  17. Manjushri says

    hi,

    I am new in Selenium Webdriver.. and i was just searching solution for authentication pop up.. you explained very well.. thanks.

    • Mukesh Otwani says

      Hi Manjushri,

      Glad to know that it helped you 🙂 Please check other section of Selenium and let me know if you are finding any issue while automating scripts.

      Thanks
      Mukesh

  18. lasertest says

    Hey! Someone in my Facebook group shared this website
    with us so I came to give it a look. I’m definitely loving
    the information. I’m book-marking and will be tweeting this
    to my followers! Excellent blog and superb style and design.

    • Mukesh Otwani says

      Hi,

      Glad to hear that you liked my blog, it gives me motivation to move forward. Thanks for sharing with your followers.

      I have couple of post Pipelined will update soon. Stay tuned 🙂

      Thanks
      Mukesh

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

AltStyle によって変換されたページ (->オリジナル) /