Posted 28 April 2022, 10:01 pm EST
- Updated 3 October 2022, 12:12 am EST
Hi Adem,
Query: Even on one of your sample pages I’m getting the same issue, it’d worked for me before;
https://www.grapecity.com/spreadjs/demos/showcase/aging-report/purejs
—> You should change the context to purejs in javascript console, and you will be able to access the GC. In the another sample(https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/purejs/), there is no iframe and you can directly access GC.
Query: however, now I’m facing a different issue where it says “window.testSpread.getActiveSheet is not a function”
—> We were unable to replicate the issue at our end. Please share a working sample with all the configurations done so that we can investigate it at our end and assist you accordingly.
You could get the spread instance using the findControl method. In the findControl method, we need to pass the host element for the spread. HostElement is the element which is passed in the Workbook constructor when creating the workbook/spreadSheet. SpreadJS provides various methods like fromJSON(), getActiveSheet(), getColumnCount(), etc, that you can use to test various functionality.
You can refer to the following code snippet.
// get hostElement
var hostDiv = webDriver.FindElement(By.Id("ss")); // where ss is id of the spread element
// get spreadInstance and save it on window object for easy access
webDriver.ExecuteScript("window.testSpread = new GC.Spread.Sheets.findControl(arguments[0]);", hostDiv);
// get Cell value of cell 0,0
var value = webDriver.ExecuteScript("return window.testSpread.getActiveSheet().getValue(0,0);");
// test value
Assert.AreEqual("1", value);
Please find the attached gif that demonstrate changing the context in console and using findControl method.
Regards
Ankit