• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

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

March 19, 2015 by Mukesh Otwani 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

Filed Under: Advance Selenium, AutoIT Tagged With: Window authentication

Reader Interactions

Comments

  1. Yoga says

    December 24, 2022 at 3:09 PM

    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?

    Reply
    • Mukesh Otwani says

      December 31, 2022 at 12:49 PM

      Hi Yoga, in Selenium 4 you can do this via CDP and for firefox, you can use RDP. It works in parallel mode too https://learn-automation.com/handle-authentication-pop-up-in-selenium4/

      Reply
  2. Pon Surya Prakash I says

    February 22, 2022 at 2:27 PM

    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

    Reply
    • Mukesh Otwani says

      March 9, 2022 at 10:41 AM

      Hi Surya, in Selenium 4 we have support for authentication. Please check below link https://learn-automation.com/handle-authentication-pop-up-in-selenium4/

      Reply
  3. Divya C M says

    November 20, 2021 at 8:31 PM

    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

    Reply
    • Mukesh Otwani says

      November 26, 2021 at 10:44 AM

      Hi Divya,

      Now using Selenium 4 you can bypass this authentication using headers.

      Thanks
      Mukesh Otwani

      Reply
  4. Poonam says

    October 15, 2019 at 3:06 PM

    suppose my username is abcd and password is abc@1234.
    Then my constructed URL should be http://abcd :abc@1234@www.xyz.com/
    How this is not working pls suggest.

    Reply
    • Mukesh Otwani says

      October 15, 2019 at 9:37 PM

      Hi Poonam,

      Encode your @ (which is into password) symbol with %40 and try it

      Reply
  5. Muthukumar says

    July 28, 2019 at 5:52 PM

    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 .

    Reply
    • Mukesh Otwani says

      July 28, 2019 at 6:41 PM

      Hi Muthu,

      You can go through this link https://www.youtube.com/watch?v=vFXL4nMWvXI&list=PL6flErFppaj0WwNOMFeXPVlNCDuJyPYFi to find answers of your queries.

      Reply
  6. sadasiba panda says

    June 27, 2019 at 7:25 PM

    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.

    Reply
    • Mukesh Otwani says

      June 28, 2019 at 12:35 AM

      Hi Sadasiba,

      Have you tried same with Robot class, if not then please refer this http://learn-automation.com/robot-class-in-selenium-webdriver/
      Here using Tab key with Control and V keys, you can achieve your objective.

      Reply
  7. Dhananjay says

    June 26, 2019 at 3:58 PM

    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.

    Reply
    • Mukesh Otwani says

      June 26, 2019 at 10:17 PM

      Hi Dhananjay,

      Ideally it should be possible but it depends on application authentication behavior.

      Reply
  8. Sujata says

    November 30, 2016 at 7:58 PM

    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

    Reply
    • Mukesh Otwani says

      November 30, 2016 at 8:13 PM

      Hi Sujata,

      For MAC i need to check some alternatives. I will update you shortly.

      Reply
  9. Priyanka says

    October 25, 2016 at 2:01 AM

    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 🙂

    Reply
    • Mukesh Otwani says

      October 25, 2016 at 1:51 PM

      Hi Priyanka,

      Sikuli works for MAC as well.

      http://learn-automation.com/integrate-sikuli-with-selenium-webdriver/

      Reply
  10. kibs says

    September 22, 2016 at 5:31 PM

    Hi,

    Through Auto It Script “Ok” click is not happening , instead focus remaining on “popup” it self.

    Reply
    • Mukesh Otwani says

      September 23, 2016 at 2:45 AM

      Hi Kibs,

      Try to add wait before click.

      Reply
  11. Ram says

    August 17, 2016 at 3:16 PM

    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.

    Reply
    • Mukesh Otwani says

      August 18, 2016 at 9:33 AM

      Hi Ram,

      Below article will help you http://learn-automation.com/handle-calender-in-selenium-webdriver/

      Reply
  12. Madhur Bharadwaj says

    August 1, 2016 at 1:30 PM

    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

    Reply
    • Mukesh Otwani says

      August 2, 2016 at 11:55 AM

      Hi Madhur,

      Can u try the same with robot class ?

      Reply
  13. Abhishek Gajra says

    July 18, 2016 at 11:52 PM

    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,

    Reply
    • Mukesh Otwani says

      July 20, 2016 at 1:57 PM

      Hey Abhishek,

      Use robot class or Sikuli for chrome if autoIT is not working.

      Reply
      • amit says

        September 22, 2016 at 12:18 PM

        Even i tried the same stuff but i am unable to see any progress nothing turned out actually.
        Can you tell me why it is not working

        Reply
        • Mukesh Otwani says

          September 23, 2016 at 2:45 AM

          Hi Amit,

          Try robot class of Java it works for me always.

          Reply
  14. selva says

    February 25, 2016 at 1:35 PM

    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

    Reply
    • Mukesh Otwani says

      March 3, 2016 at 2:14 PM

      Hi Selva,

      If you can find the pattern when it appears then Selenium can help.

      Reply
  15. RP says

    February 9, 2016 at 4:50 PM

    How to do this for Opera Brower

    Reply
    • Mukesh Otwani says

      March 3, 2016 at 4:51 PM

      Hi Rupesh,

      Sorry but I have never tried with Opera browser.

      Reply
  16. Arunkumar Ramakrishnan says

    February 6, 2016 at 11:11 PM

    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

    Reply
    • Mukesh Otwani says

      March 11, 2016 at 6:37 PM

      Hi Arun,

      This will help

      Reply
  17. Vishy says

    February 3, 2016 at 12:31 PM

    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.

    Reply
    • Mukesh Otwani says

      March 11, 2016 at 6:35 PM

      hi Vishy,

      This will help

      Reply
  18. Abhilash Pethambaran says

    January 28, 2016 at 11:14 AM

    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

    Reply
    • Mukesh Otwani says

      March 3, 2016 at 4:34 PM

      HI Abhilash,

      is it fixed? Sorry I was on long vacations.

      Reply
  19. akashsuthwal says

    December 15, 2015 at 6:30 PM

    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 ?

    Reply
    • Mukesh Otwani says

      December 17, 2015 at 8:48 PM

      Hi Akash,

      It’s very interesting part and yes it is possible with small piece of code.

      I will upload the code by this weekend.

      Reply
  20. Divya says

    December 9, 2015 at 3:35 PM

    The autoIT code that I wrote doesn’t work in Selenium. It doesn’t throw any error either. How to ensure that

    Reply
    • Mukesh Otwani says

      December 12, 2015 at 3:59 PM

      Hi Divya,

      Sorry for late reply. I am using this code and its working fine in my machine. Can you please share ur script so that I can check the exact issue?

      Reply
    • Uday says

      September 24, 2016 at 2:06 PM

      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

      Reply
      • Mukesh Otwani says

        September 29, 2016 at 11:15 AM

        Hi Uday,

        Kindly use some sleep between commands.

        Reply
        • Thejdeep G says

          October 26, 2016 at 2:34 PM

          Hi Mukesh,

          This worked for me. Thanks a ton mate.

          Reply
  21. S.Kumar says

    December 4, 2015 at 4:16 PM

    the script did not work for me!!! any other solutions?

    Reply
    • Mukesh Otwani says

      December 4, 2015 at 5:25 PM

      Hi Swamy,

      this should work.. Can u share autoit scipt which u have written?

      Reply
  22. Sooraj Hat says

    December 1, 2015 at 5:20 PM

    can you use sikuli instead of auto it for Authentication handling?

    Reply
    • Mukesh Otwani says

      December 2, 2015 at 1:05 AM

      Hi Sooraj,

      Yes you can use.

      Reply
  23. Manjushri says

    November 24, 2015 at 9:37 AM

    hi,

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

    Reply
    • Mukesh Otwani says

      November 24, 2015 at 3:09 PM

      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

      Reply
  24. lasertest says

    September 19, 2015 at 6:31 PM

    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.

    Reply
    • Mukesh Otwani says

      September 19, 2015 at 7:28 PM

      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

      Reply

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.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Best and easy way to Group test cases in selenium

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?