WebUI.authenticate method fails even though page loads

I am trying to write a simple test case for a page that requires basic HTTP authentication, but after running the WebUI.authenticate method, it will always mark the test as a failure with the cause “com.kms.katalon.core.exception.StepFailedException: Unable to navigate to authenticated page”, even though the page loads fine. This is what I am doing in my script:

WebUI.openBrowser('')
WebUI.authenticate('mypage.aspx', 'username', Decrypt.dec(), 3)
//Rest of the test case

I am running the method call Decrypt.dec() to return the password decrypted from Base64 so I do not need to write it as plain text in the authenticate step, but even if I put the password as plain text, it still marks the step as a failure. Is there any known fix for this? I am aware of FailureHandling.OPTIONAL, but it is not ideal for my situation. I am using the Chrome browser.

Hello,

you must provide a full URI including a domain name.

The URI is well formed (https://something.com/mypage.aspx). The mypage.aspx was just a placeholder. My apologies if that was not clear.

No worries.

Did you try to use https://user:pass@site.com format? In your case something like this:

WebUI.openBrowser("https://username:" + Decrypt.dec() + "@something.com/mypage.aspx")

That one seems to work, actually. I had believed the username:password@site format was depreciated, but it seems to work without any issues now. So long as this won’t be a security risk (and it shouldn’t as the tests are planned to be run as a read only, heavily secured user), this works well for me. Thank you!

Basic authentication itself should be deprecated now. :slight_smile: But as soon as you use HTTPS, it is quite safe, no matter if you use credentials in an address or in a header.

So is there anyway to do this with variables for the username and password? I have more then one user account that I need to test with.

@david.tegeler

Read the following document and find you way to follow.

1 Like

This doesn’t really answer my question. When I try to enter separate variables for each part of this it does not work. So as an exmaple I tried entering WebUI.openBrowser(GlobalVariable.userName,GlobalVariable.Password,GlobalVariable.Staging_URL)
I also tried http://userName:Password@Staging_URL Neither of these work. The variable names do not get recognized as variables even when I switched value type to variable. I think I noted in another question on this that the method noted in the document works it just returns a fail every time. It works better it just needs to be fixed so it doesn’t return fail every time when it is actually getting the right result.

Have a look at this guide

and please provide us more information: screenshots, code, log.

Pretty straight forward. WebUI.authenticate(‘http://tmcfeature16-07.tmctrans.com/DX.Home’, GlobalVariable.userName, GlobalVariable.Password, 12,
FailureHandling.OPTIONAL)

always returns this
05-07-2020 12:54:28 PM authenticate(“http://tmcfeature16-07.tmctrans.com/DX.Home”, userName, Password, 12, OPTIONAL)

Elapsed time: 9.463s

Unable to navigate to authenticated page (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to navigate to authenticated page. Reason:
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailedWithReason(WebUIKeywordMain.groovy:70)
at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword$_authenticate_closure1.doCall(AuthenticateKeyword.groovy:91)
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:72)
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 Add Directions.run(Add Directions:21)
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(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1588874059690.run(TempTestCase1588874059690.groovy:23)
)

So that in turn fails the test case. This comes up everytime I run it in Studio or from command line. When I watch it run through the test from studio it is authenticating. I know this because the web page opens, and the test completes the rest of the way without issue. I have tried Authenticate with another app, and I get the same thing. It makes me think all my tests are failing when I use this when they really are not. Does anyone know if this is a bug with Katalon? I can’t seem to find where to look for or enter bugs.

@david.tegeler

I want to check if your AUT is challenging you either by HTTP Basic Authentication or by HTTP+HTML form-based Authentication. Why? Because WebUI.authenticate keyword applies to the Basic authentication, does not apply to the Form-based authentication. If your AUT have Form-based authentication applied, then WebUI.authenticate is not the tool you should use.

I want to understand your problem first. When I tried to retrieve the URL of your Application Under Test http://tmcfeature16-07.tmctrans.com/DX.Home using Chrome browser, I got the following response.

This implies that the url is possibly not disclosed to me, is not public to the Internet. The url seems to be visible only in your private network? OK, then, @david.tegeler, could you try this?

  • retrieve the URL on your browser, see the authentication challenge where you are asked to type username/password
  • and take a screenshot of the pag
  • share the screenshot here.

I want to look at the image. If I can see the image, I can see which of authentication techniques you have.

@kazurayam, I have same problem but in IE and edge browser. Authenticate method is working fine in chrome but it is not working in edge and IE browser.

I am getting the same exception
Unable to navigate to authenticated page (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to navigate to authenticated page. Reason:
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailedWithReason(WebUIKeywordMain.groovy:70)
at com.kms.katalon.core.webui.keyword.builtin.AuthenticateKeyword

Sorry, I can not help you as I know nothing about IE browser.

@kazurayam No worries. Thanks