JS code returns value in console, but not in Katalon

Trying to validate that a particular element was found and selected on a highcharts graph, I have the JS working in the console but Katalon’s not recognizing the return value and I can’t figure out why.

Here’s the JS code:

(() => 
{
	var el = document.getElementById('page-views-scatter-plot-graph');
	var chart = Highcharts.charts.find(c => c && c.renderTo === el);
	var outerLength = chart.series.length;
	var itemClicked = false;
	for(var i = 0, lo = outerLength; i < lo && !itemClicked ; i++){
			var innerLength = chart.series[i].data.length;	
			if (innerLength > 0) {		
				for(var c = 0, li = innerLength; c < li  && !itemClicked; c++){
				var point = chart.series[i].points[c];
					if ((point.options.marker?.symbol ==='diamond') && (point.color === 'green')) {
						point.firePointEvent('click');					
						itemClicked = true;					
						return itemClicked;				
					}		
				}		
			}
	}

	return itemClicked;
				
})();

Screenshot of it working in the console:

Katalon Execute JS statement:

		String jsvaluefound = WebUI.executeJavaScript(javascript_statement, null)
		KeywordUtil.logInfo("jsvaluefound = " + jsvaluefound)

Katalon variable value after executing this portion:

![image|690x19](upload://8fUoJQ8vjl8Yyz1C1mU9XTB8mOW.png)

This is likely one of the more complex things I’ve had to do using Katalon JS executes; however I’m a bit stumped as usually if I get the console side to work the JS value is returned correctly as well, thoughts?

1 Like

??? I can`t see the image.

Please erase the pair of triple back ticks around the ![image|...