Submit button is being clicked, but seems to be stopping action

Hi community! This test has been working fine previously, but a few days ago the click method doesn’t seem to be working with this particular button. After entering credentials, you’re prompted for a 2FA, so when you click submit, the button is clicked, and you’ll be able to see on the gif, the action is perfomed and seems to be loading, but then it stops. (1)

This is the html of the button. I tried with different locators (from the div and the label), IDs are dynamic, so I used xpath or different combination of selectors, using both the Click method form Katalon and also with JavaScript executor, but nothing worked. Same result in both cases

button html

These are both the pieces of code I tried with Click:

WebUI.waitForElementClickable(findTestObject('NSVerificationPage/btnSubmit'), 20)'NSVerificationPage/btnSubmit'))

JS Executor

WebUI.waitForElementClickable(findTestObject('NSVerificationPage/btnSubmit'), 20)

WebDriver myDriver = DriverFactory.getWebDriver();

WebElement submitBtn = myDriver.findElement(By.xpath('//*[(contains(text(), "Submit") or contains(., "Submit")) and @class = "n-w-label n-widget style-button n-widget--status-none n-w-button__label n-w-text-style--wrap-truncate"]'));

JavascriptExecutor executor = (JavascriptExecutor)myDriver;

executor.executeScript("arguments[0].click();", submitBtn);

This is my first time posting here, so not sure if any other infor is needed. If anyone has any suggestion, I’d greatly appreciate it.

Try this:

String js = 'document.querySelector("#n-id-component-51").click()'
WebUI.executeJavaScript(js, null)

Hi, thanks for the reply! I just tried that solution, but unfortunatelly it’s still giving me same result.

The code I gave you will click the HTML <div> element with that id. To click the <label> element instead, try this:

String js = 'document.querySelector("#n-id-component-57").click()'
WebUI.executeJavaScript(js, null)

If that doesn’t work, then you might not be addressing the correct element. To prove the point, bring up the page in the browser and enter the following in the browser console:


So, I also tried with the second piece of code you sent, but nothing changed.
When testing that on the browser console as you mentioned, it seems it’s correctly being clicked, because this alert showed up (there were no values on the field). Unless I’m not understanding the result the way it should be.

Could it be something related to the page itself? I also tried looking at the dev console while running the test, but didn’t see anything unsusual, though I don’t know exactly what to look at either

Ah, wait… I missed that.

Try this:

String selector = "div[aria-label=Submit] > label:nth-of-type(1)"
String js = "document.querySelector('${selector}').click()"
WebUI.executeJavaScript(js, null)

Take care to copy the quotes correctly - I had to switch them around to pull in the ${selector} variable.

Here is the code to try in the browser console:

document.querySelector("div[aria-label=Submit] > label:nth-of-type(1)").click()

If it fails, put single-quotes around ‘Submit’

First, thank you so much for taking the time to provide help. Using the code just as you wrote it, it’s still behaving the same way the rest of the previous attempts. If I add the single quotes to Submit, it throws me an exception “javascript error: missing ) after argument list”

Test Cases/Steps/NS_Login FAILED.
com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
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.ExecuteJavaScriptKeyword.executeJavascript(ExecuteJavascriptKeyword.groovy:42)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.execute(ExecuteJavascriptKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$ Source)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.TestCaseExecutor.runScript(
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
at com.kms.katalon.core.main.TestCaseExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)
Caused by: org.openqa.selenium.JavascriptException: javascript error: missing ) after argument list
(Session info: chrome=105.0.5195.125)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘EZE1-LLN-B03024’, ip: ‘’, ‘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: 105.0.5195.125, chrome: {chromedriverVersion: 104.0.5112.79 (3cf3e8c8a07d…, userDataDir: C:\Users\GISELE~1.ALB\AppDa…}, goog:chromeOptions: {debuggerAddress: localhost:50189}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: efefd1b51bfbd669c2205d070498b6ed
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(
at org.openqa.selenium.remote.HttpCommandExecutor.execute(
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at com.kms.katalon.selenium.driver.CChromeDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(
at com.sun.proxy.$Proxy8.executeScript(Unknown Source)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword$_executeJavascript_closure1.doCall(ExecuteJavascriptKeyword.groovy:48)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword$
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 17 more

Does it work in the browser console?

What I noticed is that if there are no values on the field and run that script on the console, the alert of the image above shows up. Now if I enter a value (no matter if it’s a valid code or not) and run that script, the button is clicked but the action stops, just as all the other methods I tried

It’s entirely possible the page (the application) is using JavaScript to perform specific actions based on current page state. It’s your task to find out what those actions might be (it’s impossible for me to know what they might be).

Hint: Try your best to make your test script mimic the actions of a user. Said another way, don’t do things a user cannot do.

Hi there! After investigating and digging into why the click didn’t work, I realized the computer’s time was a few minutes off and since I’m using an OTP generator for the login, that was the reason it was causing issues. When the code was being generated it didn’t match the time on the computer, after syncing the clock with windows servers the tests worked fine!

I would have never guessed that was messing with my tests. I appreciate the time you took into provinding solutions