Unable to interact with Slick Grid


#1

Hi,

I am trying to extract the data from the desired column in Slick Grid which has close to 120 columns and 600 rows.

I am unable to interact with the cells as their xpaths are changing dynamically every time.

Any specific way to interact with slick grid elements in Katalon.

Any help would be much appreciated.

Thanks,
Sampath.


#2

Hi, I am trying to interact with slick grid and I used the below code

int rowCount = WebUI.executeJavaScript(‘return $(grid.getCanvasNode()).children().length;’, [])

but it is returning the error saying grid not defined.

Any help would be much appreciated.


#3

It usually helps if you post the exact error.

I’m assuming the $ is a jQuery call - correct?

Where is grid defined?

What happens if you put $(grid.getCanvasNode()) in the browser console?


#4

Thanks alot for the reply, I figured out that I have to define the grid for getting the above code to work.

The definition of the grid is as below which has to be defined for my code to work.

var grid;

var columns = [

{id: "Date", name: "Date", field: "Date"},

{id: "spn", name: "spn", field: "spn"},

];

var options = {

enableCellNavigation: true,

enableColumnReorder: true,

explicitInitialization: false

};

$(function () {

var data = \[\];

for (var i = 0; i < 500; i++) {

  data\[i\] = {

    Date: "20180612",

SPN:Math.random(),

  };

var myGrid = $("

");

grid = new Slick.Grid(myGrid, data, columns, options);

myGrid.appendTo($("#app > div > div > div > div > div.size–5.padding–horizontal–double > div.size–content > div > div > div"));

grid.init();

As the definition is multiline, I am struck here how to execute this multiline javascript code in katalon.


#5

Groovy supports multiline strings, like this:

String js = '''
This is;
some javascript;
spread over;
multiple lines;
'''

Note that’s TRIPLE single-quotes (quote-quote-quote stuff quote-quote-quote)


#6

Hi Russ,

Thanks alot for the inputs, I was able to pass the multiline js script through triple quote but I guess there is something wrong in my JS script as it is throwing Testing FAILED because (of) Unable to execute JavaScript. (Root cause: org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token ,


#7

Sounds like you have a stray comma?