Unable to handle Authentication pop-up window in IE

Hi i am facing an issue in the below scenario
On hitting the application URL a authentication pop-up comes up for entering username and password with OK and Cancel button.
I tired with authentication method
WebUI.authenticate(‘URL’,‘username’,‘pwd’)
this did not work
pls help

NOTE: Inspect element is not working in the pop-up and spy web is also not working when the window comes up

1 Like

Hi @tech_support, @katalon_store_suppor

Can you please help us / guide us on our blocker - Unable to handle Authentication pop-up window in Chrome / IE or in any browser.

On hitting the application URL a authentication pop-up comes up for entering username and password with OK and Cancel button.
I tired with authentication method
WebUI.authenticate(‘URL’,‘username’,‘pwd’)
this did not work
pls help

NOTE: Inspect element is not working in the pop-up

If this is NTLM Authentication, You will need to use javascript and custom keyword to perform the login.

In your test case:

‘Execute custom javascript to load the page that requires windows authentication’
WebUI.executeJavaScript((‘function myFunction() { setTimeout(function(){ window.location.href = ‘’ + pageURL) +
‘’; }, 500);}; myFunction()’, [])
‘perform the windows authentication using custom keyword LoginAuthenticate’
CustomKeywords.‘YOUR_PACKAGE_NAME.auth_keyword.loginAuthenticate’(username, password)

and the custom keyword:

package YOUR_PACKAGE_NAME

class auth_keyword {
@Keyword
def loginAuthenticate(String username, String password) {

	String browser = DriverFactory.getExecutedBrowser().getName()
	boolean IE = false
	if (browser.contains('IE')) {
		IE = true
	}

	println 'Browser: ' + browser

	Robot robot = new Robot();
	robot.setAutoDelay(250);
	StringSelection ss = new StringSelection(username);
	Toolkit toolkit = Toolkit.getDefaultToolkit()
	Clipboard clipboard = toolkit.getSystemClipboard().setContents(ss, null);
	robot.delay(1000);
	if (IE) {
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
		robot.keyPress(KeyEvent.VK_ENTER);
		robot.keyRelease(KeyEvent.VK_ENTER);
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
		robot.keyPress(KeyEvent.VK_ENTER);
		robot.keyRelease(KeyEvent.VK_ENTER);
	}
	robot.keyPress(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_V);
	robot.keyRelease(KeyEvent.VK_V);
	robot.keyRelease(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_TAB);
	robot.keyRelease(KeyEvent.VK_TAB);
	ss = new StringSelection(password);
	Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
	robot.keyPress(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_V);
	robot.keyRelease(KeyEvent.VK_V);
	robot.keyRelease(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_TAB);
	robot.keyRelease(KeyEvent.VK_TAB);
	if (IE) {
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
		robot.keyPress(KeyEvent.VK_TAB);
		robot.keyRelease(KeyEvent.VK_TAB);
	}
	robot.keyPress(KeyEvent.VK_ENTER);
	robot.keyRelease(KeyEvent.VK_ENTER);
}

}
2 Likes

Hi @danpoleary,
CC: @katalon_store_suppor, @tech_support
Thank you for your technical help on my blocker.
But still I am struggling to resolve my blocker or may I missing something minor where your help is highly appreciated.

As per your solution I have followed below steps-

  1. I have created new custom keyword in my Package

  2. then in my test case, I tried to execute custom javascript to load the page that requires windows authentication. Over here I am getting error as shown in below image-

Requesting you to please review and let me know what is going wrong.
Note: I have validated JavaScript Syntax using couple of online JavaScript syntax validator where no syntax error is getting displayed. But in Katalon studio for same line, Syntax error is getting displayed.

Thanks,
Ranjeet

Your executeJavaScript needs to look like:

WebUI.executeJavaScript(('function myFunction() { setTimeout(function(){ window.location.href = \'' + pageURL) +
'\'; }, 500);}; myFunction()', [])

Where pageURL is your URL.

And then call your method:

CustomKeywords.'myPackage.Auth_keyword.loginAuthenticate'(username,password)

Dan

I just noticed the single quotes wrapping your JavaScript are the wrong ones. This happens when you copy and paste from here. Change to standard single quotes and you should be fine.

Dan

2 Likes

Hi @danpoleary
CC: @katalon_store_suppor, @tech_support

Thank you very much. Your solution resolved my blocker. Thanks for your help.
Regards,
Ranjeet

1 Like

Hi,

Will this solution work on Mac as well ?

Best regards
Jasmi

It should. The window that pops up may be different, so you would have to modify the code to correctly move over and populate the elements on that window.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.