Button On click does not load page

Hello again,
I am currently working on a project where I have to add objects with certain data.
When objects are added I can access a page where I can modify them or even access a page where I can add extra data. For this, I have a page with all the objects displayed in different rows and each row has a button to do the actions I mention before. The problem is that I cannot access this pages using katalon. I even wait 5 seconds for the page to load but this does nothing and it is a little bit frustrating cause Test case passes correctly.

This is the Test Case. This works correctly but when I click the button on step 18, the page does not load.
WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘url’)

WebUI.setText(findTestObject(‘Page_Login/input_User Name_vUSERNAME’), ‘admin’)

WebUI.delay(2)

WebUI.setEncryptedText(findTestObject(‘Page_Login/input_User Password_vUSERPASSWORD’), ‘hUKwJTbofgPU9eVlw/CnDQ==’)

WebUI.click(findTestObject(‘Page_Login/input_User Password_LOGIN’))

WebUI.click(findTestObject(‘Page_Inicio/a_Analtica’))

WebUI.delay(2)

WebUI.click(findTestObject(‘Page_Ingreso y Validacion de Resultados/a_Ingreso y Validacion de Resultados’))

WebUI.waitForPageLoad(5)

WebUI.click(findTestObject(‘Page_Administracin de rdenes/span_En Proceso_caret’))

WebUI.delay(2)

WebUI.waitForElementPresent(findTestObject(‘Page_Administracin de rdenes/ul_dropDown’), 30)

WebUI.click(findTestObject(‘Page_Administracin de rdenes/a_Seleccionar Todos’))

WebUI.verifyElementNotChecked(findTestObject(‘Page_Administracin de rdenes/a_Seleccionar Todos’), 30)

WebUI.click(findTestObject(‘Page_Administracin de rdenes/input_Seleccionar Todos_BUTTON1’))

WebUI.waitForElementVisible(findTestObject(‘Page_Administracin de rdenes/div_BoxConOrdenes’), 30)

//WebUI.click(findTestObject(‘Page_Ingreso y Validacion de Resultados/img_vVER_0001’))
CustomKeywords.‘keywordPrueba.CustomFunction.clickUsingJS’(findTestObject(‘Page_Ingreso y Validacion de Resultados/img_vVER_0001’),
30)

WebUI.waitForPageLoad(5)

This is the xpath of the button I click to enter the page I want:

This is the html surrounding my button

This is my console:

Do I need to do something that I am not doing? Do you have any suggestions on what is happening? most pages load correctly so I am having a difficult time to solve this ! I think the problem occurs when I want to access a data page of an object in the system.

Try this line:

WebUI.executeJavaScript('document.querySelector("#vVER_0001").click();', null)

If that doesn’t work, please post the HTML as seen in Firefox (and make sure none of it is cut off at the margins).

Hi, I had this problem in two different buttons. In one of them, the problem was magically solved. It didnt worked yesterday and today it worked perfectly. This is the button I reference in my post.
I still have it on this button:

TC 1
WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘url’)

WebUI.setText(findTestObject(‘Page_Login/input_User Name_vUSERNAME’), ‘admin’)

WebUI.setEncryptedText(findTestObject(‘Page_Login/input_User Password_vUSERPASSWORD’), ‘hUKwJTbofgPU9eVlw/CnDQ==’)

WebUI.click(findTestObject(‘Page_Login/input_User Password_LOGIN’))

WebUI.click(findTestObject(‘Page_Inicio/a_Pre Analtica’))

WebUI.click(findTestObject(‘Page_Inicio/a_Administracin de rdenes’))

WebUI.delay(2)

WebUI.click(findTestObject(‘Page_Administracin de rdenes/span_En Proceso_caret’))

WebUI.delay(2)

WebUI.waitForElementPresent(findTestObject(‘Page_Administracin de rdenes/ul_dropDown’), 0)

WebUI.click(findTestObject(‘Page_Administracin de rdenes/a_Seleccionar Todos’))

WebUI.verifyElementNotChecked(findTestObject(‘Page_Administracin de rdenes/a_Seleccionar Todos’), 0)

WebUI.click(findTestObject(‘Page_Administracin de rdenes/input_Seleccionar Todos_BUTTON1’))

WebUI.waitForElementVisible(findTestObject(‘Page_Administracin de rdenes/div_BoxConOrdenes’), 30)

TC 2
WebUI.callTestCase(findTestCase(‘FiltracionSimple’), [:], FailureHandling.STOP_ON_FAILURE)

CustomKeywords.‘keywordPrueba.CustomFunction.clickUsingJS’(findTestObject(‘Page_Administracin de rdenes/img_Fecha Est_vMODIFICAR_0001’),
30)

WebUI.waitForPageLoad(5)

Ive tried to do that for this button but it gives me this error:
WebUI.executeJavaScript(‘document.querySelector(“#vMODIFICAR_0001”).click();’, null)
Unable to execute JavaScript. (Root cause: 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:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$7.call(Unknown Source)
at ModificarOrden(No terminado).run(ModificarOrden(No terminado):24)
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 TempTestCase1561557840429.run(TempTestCase1561557840429.groovy:21)
Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read property ‘click’ of null

Here is the hmtl in firefox of that button

You’re confusing me with two different TCs. Can we please just look at the TC that is failing…?

Katalon is saying that the element with ID vMODIFICAR_0001 is null at the time you tried to use it.

Now please click on event and show me what is revealed:

image

I added a second TC because the main one depends of the other as I make a call to it.
The main one is tc 2 and is the one that fails.

Here is my html

If you’re convinced that control (image) is the clickable element, then it must be using delegation somewhere in the chain - the only event handler is for focus.

Okay, let’s try this. Paste the following in the browser console:

document.querySelector("#vMODIFICAR_0001").click()

You can replace the ID with any of the problem elements.

If that works, then you probably have a timing issue.

1 Like

This works. I will try and find out if it is a timing issue like you said. Thanks for all the help !!!

1 Like

A post was split to a new topic: JavaScript to click element with class but no ID