Forum Discussion

chicks's avatar
chicks
Regular Contributor
13 years ago

Additional Information (testing hooks) in GUI objects

So, I have some additional information for GUI objects that I would like the developers to make accessible for me, although the information is not visible on the screen, and doesn't need to be.



For example, in the attached picture, the following information is displayed and thus accessible to my test scripts.



The reward value "15c/gal"

The title "Shell Fuel Rewards....."

The button text "sfr get ithow are u"



However,I would like to be able to access information which is available to the developers when they write the code to display the panel.  In this case, the date that this deal was created.    What's the simplest way for the developers to add this information and make it accessible to my test scripts?



We've tried adding a tag to the object, but I was unable to access it.



By the way, I'm writing my scripts in Javascript and using TC 8.6



Thanks very much.



Curt Hicks


4 Replies

  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello Curt,



    There can be multiple ways to pass the additional information along with web elements:



    1) Use some of the Tag's standard attributes:

    <p id="DateCreated:15/05/2013">Some Text</p> (the value of the id attribute should be unique across the page)

    <a href="some_url.htm" rel="DateCreated:15/05/2013">Some Link</a>



    2) Use the hidden text fields:

    <span style="display:none">DateCreated:15/05/2013</span>

    <p style="display:none">DateCreated:15/05/2013</p>



    3) Use the hidden controls (similarly to the VIEWSTATE property of ASP.NET controls).

    <form>

    ...

      <input type="hidden" name="Date Created" value="15/05/2013" />

    ...

    </form>



    Regards.
  • chicks's avatar
    chicks
    Regular Contributor
    Thanks Artem,



    So the developer will add these tags to their javascript and then I will be able to see them from the GUI objects? Is that right?



    It seems like TestComplete is only providing access to the gui objects.  I don't have any access to the javascript internal objects,only the objects that are displayed on the page.....



    Regards,  Curt
  • chicks's avatar
    chicks
    Regular Contributor
    So are these the HTML tags?    It looks like our webpages are mostly dynamically composed from javascript.   Can the javascript modify the HTML tags?





    Thanks very much.



    Regards,  Curt

  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello Curt,



    Yes, these are the objects corresponding to the HTML tags. TestComplete did not have access to the JavaScript run-time objects (except for the document and window objects), it can access only the page's on-screen objects (yet, the latter could be invisible to the end-user). That is why, I suggested your developers adding the auxiliary info to the web elements.

    >>Can the javascript modify the HTML tags?

    Yes, it is possible to add and modify the existing HTML tags from JavaScript. For instance, the following HTML appends one more paragraph to it and alters the text color through the JavaScript functions:



    <html>

    <head>

    <title>Modifying HTML body</title>

    </head>

    <script language="javascript">

         function appendp() {

                var p = document.createElement("p");

                var texto = document.createTextNode("Text.....");



                p.appendChild(texto);

                document.body.appendChild(p);

         }



           function setcol() {

                var p = document.getElementsByTagName("P")[0]

                p.setAttribute("style","color:green")

         }

    </script>



    <body>

    <p>Lorim ipsum dolores sit amen</p>

    <button onclick=appendp()>Append Paragraph</button>

    <button onclick=setcol()>Change Color</button>

    </body>

    </html>