Posted 2 June 2021, 12:52 am EST
I am trying automate spreadJs using selenium with Java. Below is my code snippet.
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement hostDiv = driver.findElement(By.id("vp_vp"));
// get spreadInstance and save it on window object for easy access
js.executeScript("window.testSpread = new GC.Spread.Sheets.findControl(arguments[0]);", hostDiv);
// get Cell value of cell 1,1
js.executeScript("return window.testSpread.getActiveSheet().getValue(1,1);");
String value = (String) js.executeScript("return window.testSpread.getActiveSheet().getValue(1,1);");
// test value
Assert.assertEquals("1", value);
This is from where I am taking canvas id:
<canvas id="vp_vp" gcuielement="gcWorksheetCanvas" width="1836" height="1" style="width: 1530px; height: 1px; cursor: default;" xpath="1">You need a browser which full supports HTML5 Canvas to run SpreadJS</canvas>
I am getting ‘GC not defined’ error. Could you please check & let me know whats wrong?
Please note, in my application, spreadJs is not used inside sandbox or iFrame.