Forum Discussion

SaravanaKumar_N's avatar
SaravanaKumar_N
Contributor
6 years ago

Need help with contentDocument.Script.eval

Hi All,

I need a help with contentDocument.Script.eval option.

https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html

 

Our Web application, has some wrapper values for few elements. And we have to verify those values...

If it is direct element I am able to access it using...

pageObject.contentDocument.Script.eval("document.getElementsByClassName('"+ elementClassName + "')[0].wrapper.stem.data");

 

But if it has some parent - child relation, I am not able to figure out the solution. I have given an example using Smartbear website (this website does not have wrapper values).

As shown in the picture below, first I have to access the "Support" Footer (PARENT) and then just go through all its Footer-link [CHILD] wrapper values. Is there a better way I can do this in pageObject.contentDocument.Script.eval

eval

 

 

Any help would be greatly appreciated.

 

Thanks,

Saravana

5 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    Is there any reason for not using Test Complete's built in mapping and find functions? I have found that to be the most reliable method. 

    • SaravanaKumar_N's avatar
      SaravanaKumar_N
      Contributor

      cunderw

      My objective is to access the Web Elements "wrapper".

      Any way it does not matter for me. Is there a way to acccess it using TestComplete build-in methods?

       

      • SaravanaKumar_N's avatar
        SaravanaKumar_N
        Contributor

        We use these wrappers extensively in Selenium (with help of JavaScript executor).

         

        It's very simple to access in TestComplete but the way it return the values hinted me that TC does not handle these stuffs.

        Looks like potential issue with TestComplete when handling wrapper "objects" (may be known issue).

         

        As shown in below picture, see...

        [1] -- webElements is an array founded the elements using QuerySelectorAll. webElements [0].wrapper evaluated as Object, but when I inspected it, its just empty  

        [At this point, I moved on searching for someother solution and started exploring contentDocument.Script.eval]

        [2] --- Same as [1], no details dispalyed for the object "Data"

         

        [3] --- When I accessed the Object Data property "C3", corresponding String value is displayed

        [It would be better 'Object' wrapper values also considered]

         

        Thanks,

        Saravana