SpreadJS Automation with SmartBear TestComplete

Posted by: abubakkar.siddique on 18 January 2021, 8:23 pm EST

  • Posted 18 January 2021, 8:23 pm EST

    Hi,

    I was automating our web application which also contain GrapeCit SpreadJS sheets.

    Seems lile it has HTML canvas object and TestComplete is not picking it up. Please guide me how I can automate SpreadJS with TestComplete?

    Regards,
    AbuBakkar
  • Marked as Answer

    Replied 20 January 2021, 10:23 pm EST

    Hi AbuBakker,

    You need to write the script test for testing the Spread using the TestComplete. Please refer to the following code snippet and let us know if you face any issues.


    function Test1()
    {
    //Opens the specified URL in a running instance of the specified browser.
    Browsers.Item(btChrome).Navigate("https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/purejs/");
    Aliases.browser.BrowserWindow2.Maximize();
    var page = Aliases.browser.Page("https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/purejs/")
    var document = page.contentDocument
    var GC = page.contentDocument.Script.GC;
    var spread = GC.Spread.Sheets.findControl(document.getElementById("ss"))
    Log.Message(spread.getActiveSheet().name())
    }


    Regards
    Avinash
  • Replied 14 April 2021, 5:58 pm EST

    Hi Avinash,

    thanks a lot for the reply. I just able to run above function in TestComplete.
    However, our application is written in React. So, can you please let me know how i can automate the same above function in React ? as it is giving error in TestComppelte on React sample page.

    this is the page:
    https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/react/

    Thanks.
  • Replied 15 April 2021, 9:42 pm EST

    Hi,

    Please make sure you have exposed GC object to global so that the test complete script can access the GC Object. Please refer to the following code snippet and let us know if you face any issues..


    import * as GC from "@grapecity/spread-sheets"
    window.GC = GC;


    Further, You may also refer to the following thread we discussed the similar issue.
    https://www.grapecity.com/forums/spreadjs/cypress-test-

    Regards
    Avinash
  • Replied 20 April 2021, 8:16 pm EST

    Hi,

    My TestComplete project is written in JavaScript. Please guide me how I can add above snippet in it ?

    Thanks.
  • Replied 21 April 2021, 10:40 pm EST

    Hi AbuBakker,

    You don't add anything to the test complete script. You just need to expose the GC object in the project that you are testing so that test complete can access the GC object. Please refer to the following code snippet and let us know if you face any issues.


    //add this to the React project
    import * as GC from "@grapecity/spread-sheets"
    window.GC = GC;

    // TestComplete Script should be
    function Test1()
    {
    //Opens the specified URL in a running instance of the specified browser.
    Browsers.Item(btChrome).Navigate("https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/purejs/");
    Aliases.browser.BrowserWindow2.Maximize();
    var page = Aliases.browser.Page("https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/purejs/")
    var document = page.contentDocument
    var GC = page.contentDocument.Script.GC;
    var spread = GC.Spread.Sheets.findControl(document.querySelector("div[gcUIElement='gcSpread']"))
    Log.Message(spread.getActiveSheet().name())
    }


    Regards,
    Avinash
  • Replied 21 April 2021, 10:51 pm EST

    Hi
    in your code snippet, you have mentioned JavaScript example not React.
    I am trying with SpreadJS following demo page of React.

    https://www.grapecity.com/spreadjs/demos/sample/showcase/aging-report/react/

    and getting error from TestComplete with above snipet:
    JScript runtime error.

    'Spread' is null or not an object

  • Replied 22 April 2021, 10:00 pm EST

    Hi Abubakker,

    We are sorry but you could test our online react demo because we haven't expose the GC object to the window. You need to expose the GC object in your react project.

    Regards
    Avinash
Need extra support?

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

Learn More

Forum Channels