SpreadJS 16.1 with Selenium tests

Posted by: petri.rasanen on 8 May 2023, 11:35 pm EST

  • Posted 8 May 2023, 11:35 pm EST

    Hi,

    With SpreadJS 16.0 I was able to trigger events in Selenium tests like this:

    var sheet = spread.getActiveSheet();

    sheet.Du().trigger(“CellDoubleClick”, {

    sheet: sheet,

    sheetName: sheet.name(),

    sheetArea: 3,

    row: 3,

    col: 5

    });

    Other events we used to trigger were “ActiveSheetChanged” and “CellClick” (to click on header column for sorting).

    Now with SpreadJS 16.1 version Du() is not supported anymore. How could we trigger events in Selenium? We must perform these kind of tests in our program, because these events have code that must be tested.

    Br,

    Petri

  • Posted 9 May 2023, 11:15 pm EST

    Hello Petri,

    Please note that you are using a method the sheet.Du() which is not exposed in the public API. This method is an internal method which is minified and uglified when SpreadJS files are build. It is not recommended to use this method (or other methods which are not exposed in public API) as its name may change in the future versions.

    Instead of performing double click operation with sheet.Du().trigger() method, you need to perform double click operation with the help of selenium. This is the recommended way to perform the double click operation.

    When the selenium web driver opens a web page, you can get the SpreadJS instance using GC.Spread.Sheets.findControl() method. You can find the co-ordinates of any cell on sheet using sheet.getCellRect() method and perform double click operation with selenium based on cell co-ordinates.

    Please refer to the attached selenium sample with c# which demonstrates how you can find co-ordinates of cell by executing javascript in the web page’s context.

    Please let us know if you face any issues. You may refer to another forum case that discusses similar issue: https://www.grapecity.com/forums/spreadjs/programmatically-trigger-gc-spread-sheets-events-selectionchanged

    Doc references:

    GC.Spread.Sheets.findControl():https://www.grapecity.com/spreadjs/api/v16/modules/GC.Spread.Sheets#findcontrol

    sheet.getCellRect():https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Worksheet#getcellrect

    Regards,

    Ankit

    Sample: SaleniumTest.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels