SpreadJS and selenium

Posted by: razsingh on 8 September 2017, 9:54 am EST

    • Post Options:
    • Link

    Posted 8 September 2017, 9:54 am EST

    Hi,

    We are using SpreadJS and want to test it using webdriver selenium.

    any ideas?

    Raz

  • Posted 8 September 2017, 9:54 am EST

    Hello,

    SpreadJS should work with Selenium Web Driver.

    Let us know if in case you face any issue with the same.

    We would be happy to assist you.

    Thanks,

    Reeva

  • Posted 8 September 2017, 9:54 am EST

    Hi there,

    I am trying to read a value from a cell using the following javascript under selenium, but its always returns null. Any idea why its always returning null?

    [csharp]var js = driver as IJavaScriptExecutor;

    if (js != null){

    var data = js.ExecuteScript(“var spread = new GcSpread.Sheets.Spread(document.getElementById(arguments[0])); var spreadNS = GcSpread.Sheets; var sheet = spread.getActiveSheet(); return sheet.getValue(1, 7);”,

    “spreadsheet-0vp_vp”) as string;

    }[/csharp]

  • Posted 8 September 2017, 9:54 am EST

    Hello,

    We have escalated your issue to the concerned team.

    130723 is tracking id for your issue.

    We will notify you as soon as we hear anything from them.

    Thanks,

    Reeva

  • Posted 8 September 2017, 9:54 am EST

    Hi,

    Could you please elaborate on how SpreadJS is compatible with Selenium? There is no data other than the element ID in the DOM since everything is done on canvas. The only way we are aware of automating SpreadJS withselenium is with javascript calls. Is there another way to use Selenium with SpreadJS?

    @Reeva said: Hello,

    SpreadJS should work with Selenium Web Driver.

    Let us know if in case you face any issue with the same.

    We would be happy to assist you.

    Thanks,

    Reeva

  • Posted 8 September 2017, 9:54 am EST

    Hello,

    The context of your code segment isn’t complete, we couldn’t see anything from it.

    Here is some worked sample code:-

    [csharp]

    var webDriver = new OpenQA.Selenium.Chrome.ChromeDriver();

    webDriver.Navigate().GoToUrl(“http://localhost/test.html”);

    var hostDiv = webDriver.FindElement(By.Id(“spreadDiv”));

    //Create spreadJS

    webDriver.ExecuteScript(“window.testSpread = new GcSpread.Sheets.Spread(arguments[0]);”, hostDiv);

    //Set Cell Value

    webDriver.ExecuteScript(“window.testSpread.getActiveSheet().setValue(0,0,‘1’);”);

    //Get cell value

    object value = webDriver.ExecuteScript(“return window.testSpread.getActiveSheet().getValue(0,0);”);

    Assert.AreEqual(“1”, value);

    [/csharp]

    Hope it helps. Else please elaborate more on your query. So that we can investigate on the same further.

    Thanks,

    Reeva

  • Posted 8 September 2017, 9:54 am EST

    Hi,

    Could you please post the correct javascript code I would have to passthrough in order to set the value on a ComboBoxCell? I have tried setValue which only works after I have manually clicked on the drop down arrow but it does not work if I use javascript to set the cell as active without manually clicking the cell.

  • Posted 8 September 2017, 9:54 am EST

    Hello,

    Please go through this documentation link for setting values in ComboBoxCellType:-

    http://sphelp.grapecity.com/webhelp/SpreadJSWeb/webframe.html#cellcombo.html

    Hope it helps.

    Thanks,

    Reeva

  • Posted 8 September 2017, 9:54 am EST

    @Reeva said: Hello,

    Please go through this documentation link for setting values in ComboBoxCellType:-

    http://sphelp.grapecity.com/webhelp/SpreadJSWeb/webframe.html#cellcombo.html

    Hope it helps.

    Thanks,

    Reeva

    Hi,

    I have seen that documentation as well as all the other documentation for ComboBoxCellTypes. The documentation in the link does not provide a way to programmatically change the value of a drop down. It only shows how to initialize a new combo box cell. Furthermore, calling setValue on the combo box cell does not work either unless the cell has been manually clicked first so that the DOM element has been created. I am unable to programmatically create the DOM element using the method in BaseCellType class because for some reason it is unavailable.

  • Posted 8 September 2017, 9:54 am EST

    Hi,

    Any updates on the above post? This is kind of a big issue for us as we can’t implement a fully automated test suite without this.

  • Posted 8 September 2017, 9:54 am EST

    Update, I figured out a solution for us. If there is an official way of doing this though, I would still like to know. Thanks!

  • Posted 8 September 2017, 9:54 am EST

    Any update on the post mentioned here (automation tool: selenium)

    I also faced same issue while automating the drop down list in spread js as I am unable to find an unique id .

    We are not able to select values from dropdown and drag data as the element location cannot be identified from spreadsheet (spreadsheet shows a single div/canvas only)

    Things i could do perform using robot class are

    • Delete data from spreadsheet

    • Find and Replace data in spreadsheet

    • Also able to enter text in cell for query\feedback column

  • Posted 8 September 2017, 9:54 am EST

    We had the same problem but found a solution for this in the end.

    The developers created a function for me ‘getSpread()’ which just returns the spread object. From there on you can then create any type of script you want and fire it via Selenium.

    Examples of javascript:

    First you have to create the object using this function:

    window.spread = getSpread(); // Needed to create the window.spread object so we can talk with it

    After that you can use all standard methods on it

    • spread.getSheet(0).setActiveCell(${ROW},${COLUMN}); // this will put a cell in edit mode so you can change the value
    • return spread.getSheet(0).getValue(${ROW},${COLUMN}); // get the value of a cell

    In Selenium you would call it like this:

    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;

    return js.ExecuteScript(script);

    1 - js.ExecuteScript(script_for_creating_spreadobject);

    2 - Object cellValue = js.ExecuteScript(script_to_return_cellValue);

    I don’t know if there are nicer or better solutions but this works quite good and gives me all the freedom I need for testing the grid

  • Posted 23 April 2019, 9:32 am EST

    Hi Team,

    Any update for this, since we are also facing the same.

    Could you please elaborate on how SpreadJS is compatible with Selenium? There is no data other than the element ID in the DOM since everything is done on canvas. The only way we are aware of automating SpreadJS withselenium is with javascript calls. Is there another way to use Selenium with SpreadJS?

    Thanks,

  • Posted 2 September 2019, 11:50 am EST

    Hi there,

    I’m trying to test with cypress. Is there a sample test on cypress as well?

    Thanks

Need extra support?

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

Learn More

Forum Channels