Bug with keyword Execute JavaScript

There some bug with keyword Execute Javascript

I need to use in without arguments
When I try to do it for the first time and write this:

def ForAssert = WebUI.executeJavaScript(findTestData('JavaScriptHelper').getValue(1, 1), null)

After save and run test working normal, but after close test, open it again I see this

Caused by: com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
	... 19 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Cannot read property 'value' of null

Here when I open the keyword

I think this is bug, please fix it

(Moved this from the Katalon Analytics category to the more appropriate Katalon Studio category.)

Looking at this part of the error:

your problem actually isn’t the null argument. What’s happening is that findTestData('JavaScriptHelper') is returning null. Please make sure that you have a data file at the location you’ve specified.

Also, I don’t understand your use of the WebUI.executeJavaScript() method here… Usually you use this method to do exactly that; execute some JS code, for example:

WebUI.executeJavaScript("console.log('Hello world!')", null)

Trying to execute:

findTestData('JavaScriptHelper').getValue(1, 1)

as JS code doesn’t make any sense. Unless the value you are expecting to be returned by getValue(1, 1) is a JS code snippet, which is fine, if not a little odd…

1 Like

If your just trying to get the value from a data file just follow this instead of using js. Not sure why you are even attempting to use JS

//get data
def data = findTestData('Data Files/DB Data')
// Get specific data (column, row) as a variable
String record = data.getValue(3, 4)
//print my variable
println record

Well, findTestData returns a TestData object (interface actually). Methinks here endeth the story.


Right, but then he’s doing getValue(1, 1), which returns whatever is in the first cell of the Test Data as a String, which could be a JS code snippet.

1 Like

Which would be exceedingly…

Well, let’s leave it there :confused:

I know what happen.
I write case (in data file stored JS code snippet) I need this.
I see that Execute JS need arguments, but I don’t have them, I read docs, and see that i need to write like this

WebUI.executeJavaScript("return alert("Hello world"), null)

Ok, write it, run it’s work, great
I save test case, next day open project, open test case and try to run it again. And got this error.

This works only for the first time, after save, reopen test case it not working.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.