[WebUI] Authenticate


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/webui-authenticate.html

I tried basic authentication method and it is not working on my site it is working on website mention in script

Does the authenticate keyword require that the login be in a dialogue box rather than part of a web page?

It’s not working for me on a page that is a login screen.

same problem here, authenticate does not work :frowning:

always getting same error:

Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to navigate to authenticated page
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.authenticate(AuthenticateKeyword.groovy:49)
at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.execute(AuthenticateKeyword.groovy:42)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.authenticate(WebUiBuiltInKeywords.groovy:2687)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$authenticate$0.call(Unknown Source)
at NGAuthLogin.run(NGAuthLogin:25)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:331)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:322)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:293)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:227)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1553163100585.run(TempTestCase1553163100585.groovy:21)

Edit:
saw this on other forums and this helped me:

WebUI.openBrowser(’’)

WebUI.authenticate(‘URL’, ‘user’, ‘pass’, 12, FailureHandling.OPTIONAL)

it will not get you pass result but will move past the error and you will still be able to run your tests further.

Can other forms of authentication be used, such as browser-loaded PKI/SSL certificates?

Guys try this, it is small walkaround but it is pretty useful :slight_smile:

WebUI.navigateToUrl(‘https://usernam:password@www.demo.io/’)

I see many of them had an issue with using the WebUI.authenticate() method.
You could get past the authentication but you could still see the error ‘Unable to navigate to the given url’

This got solved on adding a delay ,i.e. WebUI.delay(5) after the authenticate step.
Once i added this delay the script continued execution and passed all the verification i had for the page.

Thanks, It is working :slight_smile:

The issue is still valid for me
I tried straightforward method and workarounds. So this is what I tried

  1. WebUI.navigateToUrl(‘https://LOG:PASS@ULR’)

  2. WebUI.authenticate(‘URL’, ‘LOG’, ‘PASS’,
    5, FailureHandling.OPTIONAL)

  3. I even used both ‘navigateToUrl’ and ‘authenticate’ methods in the same test case

  4. I used delays before and after each step

This is the log

> 10-08-2019 02:04:26 PM authenticate("https://***", "***", "***", 5, OPTIONAL)
> 
> Elapsed time: 0.172s
> 
> Unable to navigate to authenticated page (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to navigate to authenticated page
> 	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
> 	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.authenticate(AuthenticateKeyword.groovy:49)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.execute(AuthenticateKeyword.groovy:42)
> 	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
> 	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.authenticate(WebUiBuiltInKeywords.groovy:2670)
> 	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$authenticate$0.call(Unknown Source)
> 	at Login To Training ENV.run(Login To Training ENV:23)
> 	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
> 	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
> 	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
> 	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
> 	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
> 	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
> 	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
> 	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
> 	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
> 	at TempTestCase1570568655546.run(TempTestCase1570568655546.groovy:21)
> Caused by: org.openqa.selenium.InvalidArgumentException: invalid argument
>   (Session info: chrome=77.0.3865.90)
> Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
> System info: host: 'AVW010', ip: '142.32.18.87', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
> Driver info: com.kms.katalon.selenium.driver.CChromeDriver
> Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 77.0.3865.90, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce..., userDataDir: C:\Users\maxs\AppData\Local...}, goog:chromeOptions: {debuggerAddress: localhost:33184}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
> Session ID: 4961411c15011ab09d29bd764c060956
> 	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
> 	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
> 	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
> 	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
> 	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
> 	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
> 	at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:20)
> 	at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277)
> 	at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:857)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.isNavigateOnChromeFirefoxSuccess(AuthenticateKeyword.groovy:102)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword$_authenticate_closure1.doCall(AuthenticateKeyword.groovy:79)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword$_authenticate_closure1.call(AuthenticateKeyword.groovy)
> 	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.authenticate(AuthenticateKeyword.groovy:49)
> 	at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword.execute(AuthenticateKeyword.groovy:42)
> 	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
> 	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.authenticate(WebUiBuiltInKeywords.groovy:2670)
> 	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$authenticate$0.call(Unknown Source)
> 	at Script1570563058583.run(Script1570563058583.groovy:23)
> 	... 10 more
> )

Just in case this helps someone else…

I just ran into this exact error. For my particular case, I figured out that it has to do with the fact that the site is redirecting to a new url after authentication. For some reason this is throwing the error. To fix this, I changed the url parameter for WebUI.authenticate to be the url it redirects to after successful authentication. Now the test runs start to finish with no problems.

hello @chad note that i’m still facing the error “Unable to navigate to authenticated page”, i tried to change the URL as advised by you, but no success. can you please advise

@jayeshL can you advise please what you did to get it work, since i’m keep getting “Unable to navigate to authenticated page”

Hello, I would like to set my password in authenticate as encrypted text or invisible for other users how can I do it? Is there any option for this case?

hi all, i have face the same issue but then i manage to fix it…this is the method how i did it.
Steps 1:
in your open browser script give the credential as this:
WebUI.openBrowser(‘http://USERNAME:PASSWORD@example.com’)
Step 2:
Now navigate the url as this:
WebUI.navigateToUrl(‘http://xxx@example.com’)

That’s it now save and run…hopefully it will help you

That did the trick. I got redirected to /site/login and after i extended my global variable with this, i got no error when i use WebUI.authenticate. Thank you! :+1:

Did not work for me.

Tried all three methods, authenticate(), navigateToUrl and openBrowser.

One thing to highlight is, the user id i tried was having domain portion and a period.
For example : domain.com\user.one

Errors ass below:

When used authenticate:

Unable to navigate to authenticated page (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to navigate to authenticated page.

When used navigatetourl:

Unable to navigate to ‘http://domain.com\user.one:passw#ord@192.111.111.239/main.aspx

When used opeenbrowser:

Unable to open browser with url: ‘http://domain.com\user.one:passw#ord@192.111.111.239/main.aspx

Ok… got it worked for me now.
I just had to replace the “” with url encoded value “%5C”. And it worked for me.
happy me…

I need to have my url to be a variable because I need to use the automation test case in more than one environment. I tried using a variable on the Open Browser as follows http://userName:Password@GlobalVariable.Staging_URL. This does not work it goes to open the browser and inserts the url as GlobalVariable.Staging_URL Can someone help me use this method so I can have it look at the variable? Also I would prefer to use the other method. As originally described in this document for the WebUI Authenticate. It it’s more versatile and works fine. It seems that it needs a bug fix for the the fail response. Why would you return a fail when it is successful?

It probably should work like this i think.
I dont have an environment right now where i can test this…
But it should attach the URL to the String.
Please let me know if it worked…

WebUI.openBrowser(“http:// USERNAME:PASSWORD @”+GlobalVariable.Staging_URL)

1 Like

Here is what I ended up with, and then it worked. WebUI.openBrowser(((((‘http://’ + GlobalVariable.userName) + ‘:’) + GlobalVariable.Password) + ‘@’) + GlobalVariable.URL)

Your suggestion got me started in the right direction though, so thanks for your help!

1 Like