UI Testing - Logins using a Javascript Popup


#1

I am currently trying to build a UI testing script that runs through a series of applications, testing that a user can log into each of them. In one particular application, the login information is not entered on the page itself, but instead in a Javascript pop-up box.

I tried to build my script just using Katalon Recorder, but it looks as if I’ll need the full Studio to run this test. How would I be able to select the input sections in a Javascript Popup to enter the Username and password, then submit them?


#2

Hi Matthew

Assuming you mean a window.prompt dialog (https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt) then try this:

https://docs.katalon.com/display/KD/[WebUI]+Set+Alert+Text


#3

I’m not certain, it looks to be that. I’ll have to work using that script, but it seems to only work for window prompts with one input field, not two. How would one select the second, then press enter?


#4

Then it’s not that dialog.

You see, strictly speaking, there is no such thing as a “JavaScript Popup” - 99% of the time it’s either using HTML or a browser-based popup/window (there’s a 1% chance it’s some other embedded code like flash et al).

Outside of testing, when you run your AUT and this popup appears, what happens when you right-click on it? Do you see a menu with “Inspect element”?

If you see nothing, give it the focus (click somewhere in its body) and hit the context key (sometimes called the menu key - the one next to the right-control key) – see anything now? If nothing, hit F12 – do the developer tools appear? (then it’s a browser window).

I’m trying to figure out if all you have is a popup browser window with most of its controls removed (address bar etc.)

Post a screenshot… that would help possibly.

Russ


#5

When I right-click on the element, nothing happens; I don’t get a context menu when I right click or when I use the context key. F12 does bring up the developer tools. I’ve attached a screenshot:

Login.png


#6

https://docs.katalon.com/display/KD/[WebUI]+Authenticate


#7

Thanks; I won’t be able to confirm this until my sysadmin approves Katalon Studio installation.


#8

OK, so here’s the issue I ran into with running the ‘Authenticate’ command in Katalon Studio;

The way the website is set up, there is an automatic proxy redirect to a warning banner and link splashpage if you try to access the page directly using the url. You can only access it via the link. So, the Authenticate command fails because it cannot navigate to the page.


#9

Matthew Miyares said:

OK, so here’s the issue I ran into with running the ‘Authenticate’ command in Katalon Studio;

The way the website is set up, there is an automatic proxy redirect to a warning banner and link splashpage if you try to access the page directly using the url. You can only access it via the link. So, the Authenticate command fails because it cannot navigate to the page.

I also have a similar problem. I use ‘WebIU.authrnticate(url, user, pwd)’ command and the browser driver navigate to the url and login successfully. However, the error still happen,
it said : [Unable to navigate to authenticated page]
How can i fix it, or any other ways to login to the site via javascript prompt?


#10

For some reason, I am getting the following error "
Unable to navigate to authenticated page (Root cause: java.lang.Exception: Unsupported platform (only support Windows))" from testing on chrome. And I get access denied from Firefox. Is there a solution to it?


#11

I have the same error. Unable to navigate to authenticated page.
Also, do I need to have this line before the WebUI.authenticate command? Seems like redundant:

WebUI.navigateToUrl

As per example in https://docs.katalon.com/display/KD/[WebUI]+Authenticate , it seems that there is a specific URL for the pop-up (http://xxxxx/basic_auth). How would I know that?


#12

Matthew Miyares said:

When I right-click on the element, nothing happens; I don’t get a context menu when I right click or when I use the context key. F12 does bring up the developer tools. I’ve attached a screenshot:

@Matthew Miyares You can create test case scripts below

WebUI.navigateToUrl(‘https://Username:Youpssword@trifacta.caadsdev.qualitynet.org’)

Goodluck ! :slight_smile:


#13

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
> )