? QA Design Gurus: Handling Authentication Window with Selenium WebDriver

May 10, 2016

Handling Authentication Window with Selenium WebDriver



There are times when we get an authentication pop-up window when we hit the application URL based on the authentication type set by the application servers. How do we handle such kind of pop-ups?

If they were JavaScript browser pop-ups, we could have handle using selenium webdriver. However, there are cases, when those pop-ups are thrown by the operating system as part of network policy. In this we can handle those pop-ups in two ways.

  1. Providing username and password as part of the URL

Unfortunately, this trick will work for Firefox and Chrome, but not for IE. To handle in IE, we have to use AutoIt tool.

  1. Using AutoIt tool
First download and install the AutoIt software from https://www.autoitscript.com/site/autoit/downloads/ and write the AutoIt script as follows:

WinWaitActive(“windows security”)
Send(“testuser”)
Send(“{TAB}”)
Send(“password”)
Send(“{ENTER}”)

Save the file as login.au3 and compile the script, will get login.exe file. Execute the login.exe file using JAVA after opening the Application URL.

Public class Demo {
            Public static void main(String[] args) {
                        System.setProperty(“webdriver.ie.driver”,”C:\IEDriverServer.exe”);
                        WebDriver driver = new InternetExplorerDriver();
                        driver.manage().windows().maxmize();
                        driver.get(“https://www.engprod-charter.net/”);
                        Runtime.getRuntime().exec(“C:\\login.exe”);
            }
}

No comments:

Post a Comment