How to handle Windows Security pop up in IE [Windows 10] using Selenium

10,102

You can use Raj's answer but you don't need to use the Sikuli framework. You can use the java.awt.Robot to send keystrokes to the Windows security popup. In the example below the robot is keying a user ID of "U", then tabbing to the password box, keying a password of "P", and keying the Enter key to close the popup.

   Robot robot = new Robot();
    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
    try{
        driver.get("URL");
    } catch (TimeoutException e){
        robot.keyPress(KeyEvent.VK_U);
        robot.keyPress(KeyEvent.VK_TAB);
        robot.keyPress(KeyEvent.VK_P);
        robot.keyPress(KeyEvent.VK_ENTER);
    }

Hope It will help you.

Share:
10,102
user2283704
Author by

user2283704

Updated on June 06, 2022

Comments

  • user2283704
    user2283704 almost 2 years

    So I'm using Selenium Webdriver. On my machine running Windows 7, I can handle the Windows Security pop up using

    driver.switchTo().alert().authenticateUsing(new UserAndPassword([Credentials]));
    

    But in Windows 10, I cannot. The program doesn't recognize it as an alert and just pauses until it terminates. I've tried researching similar issues but have had no luck. This is still working in IE as well, not in Edge.