Sampath Kumar
Katalon Apprentice
06/11/2018

Unable to interact with Slick Grid

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.
Upvote
Quote

Comments

  • Sampath Kumar
    Katalon Apprentice
    06/13/2018
    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.

    Upvote
    Quote
  • Russ Thomas
    Katalon Expert
    06/13/2018
    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?


    Upvote
    Quote
  • Sampath Kumar
    Katalon Apprentice
    06/13/2018
    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 = $("<div id='MovementTracker' style='height: 399px; overflow: hidden; outline: 0px; position: relative;'></div>");

    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.
    Upvote
    Quote
  • Russ Thomas
    Katalon Expert
    06/13/2018
    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)
    Upvote
    Quote
  • Sampath Kumar
    Katalon Apprentice
    06/15/2018
    edited June 15
    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 ,
    Upvote
    Quote
  • Russ Thomas
    Katalon Expert
    06/15/2018
    Sounds like you have a stray comma?
    Upvote
    Quote
Sign In or Register to comment.