Forum Discussion

detached31's avatar
detached31
Occasional Contributor
6 months ago

Difference in JavaScript support with TC 15.61

I have some code which retrieves a JavaScript variable (a boolean value) from a Web page, in a test script (JScript).

var oPerfs = Sys.Browser("*").WaitPage("*",10000).
   contentDocument.script.
   com.sap.powerdesigner.web.galilei.features.performance;

This worked (always) with TestExecute 15.55.53.11 with Chrome 121.0.6167. (and we then use the oPerfs variable to set the JavaScript variable to true, and activate some performance counters in the page, that we later retrieve from some JS variables in the ...web.galilei.features namespace).

This fails repeatedly with TestExecute 15.61.1.11 with the same Chrome: 'sap' is null or not an object.

All the Chrome are using the 15.0.4 Smartbear Test Extension.

(as a side note, it fails with any version of TE with Chrome Beta 122)

Should it work?

8 Replies

  • MarkHays's avatar
    MarkHays
    Occasional Contributor

    Sounds Similar to some of the issues we have experienced as well.   

    In version 15.57 we were able to make a call using contentDocument.Eval() and it worked fine.  Versions after that it do not work.   After many months and asking for feedback on this issue, TestComplete Support finally, said that the eval function was deprecated by Chrome/Javascript.   It is my understanding this was related to Chrome moving to Manifest version 2.   So, the newer versions of TestComplete work with Manifest version 2.  Older versions of TestComplete worked with manifest version 1 which allowed the call to the eval function.  We are currently exploring an option of attempting to call the functions directly (and bypassing the eval function) by using contentDocument.Script.functionname(), but that is not working in version 15.64 of TestComplete.    

    • detached31's avatar
      detached31
      Occasional Contributor

      My code is not using eval(), at least visibly.

      You were lucky to get a hint from the support...

      • MarkHays's avatar
        MarkHays
        Occasional Contributor

        Started copying the Sales person on the requests for updates to the open ticket.   Would go back every couple of weeks with another email requesting an update and complaining about lack of support.  Sales did eventually get someone else involved, and a few months later finally got the response there is nothing they can do, and that was when they mentioned the Manifest version.   I did have some other open issues as well, that were not getting addressed in a timely manner, so those were included in my complaints as well.   

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Are you able to call *feature.performance in Chrome DevTools, and does it work?

  • detached31's avatar
    detached31
    Occasional Contributor

    Yes, it works in DevTools. I see an object, with sub-objects: DebugCounter, Measure, Performance (again), logger, root...
    The following test script line does "oPerfs.root.active = true;". And I can see this boolean ...performance.root.active in Chrome DevTools. (also in Firefox 122, or MS Edge 121)

  • detached31's avatar
    detached31
    Occasional Contributor

    I have submitted a case on February, 9, which is still on-going.

    After some further tests, the behavior change happened between TC 15.57, and 15.58.

    I have submitted a simple reproduction case: a HTML page with some JavaScript elements:

        <script>
    var globalVar = "global var";
    var obj = { "a": 20, "b" : function() { return "obj.b return"; } };
    var editedByEval = 10;
    function getSomeValue() { return "get some value"; }
    function setEditedByEval(val) { if (val != null) { editedByEval = val; } return editedByEval; }
        </script>

    I'm loading the page with Chrome. And there is a JavaScript TestComplete script which accesses these elements (with value check, and exception processing removed):

    var page = Sys.Browser("*").WaitPage("*");
    var g = page.contentDocument.Script.globalVar;
    g = page.contentDocument.Script.obj.a;
    g = page.contentDocument.Script.getSomeValue();
    g = page.contentDocument.Script.obj.b();
    page.contentDocument.Script.eval("setEditedByEval(30);");

    Starting with 15.58, all these elements under .Script, are undefined (which might trigger an exception when accessing a sub-object, e.g. ".Script.obj.a")

    • rraghvani's avatar
      rraghvani
      Champion Level 3

      The functionality is broken in the latest version, but works fine in v15.55.53.7