Forum Discussion

vinodtc's avatar
vinodtc
Contributor
14 years ago

How the Exists function working in webtesting

Hi,



As part of my web testing , i have to execute the testcomplete scripts on web when ever there is a new installation on my  web application. I have created different functions by scripting(VB script) and each function is a scenario for me (I have 20 scenarios). Calling these functions in main function as shown below. Problem is, some of the objects are not identifying while script execution and whole script is failing. I have used Exists method to determine the object exists or not and performing the operation on that. Still i am getting run time error. If one function fail with reason of "object not found", no other functions/scenarios are execting and just it is comming out. Please let me know how to use Exists method to identify the objects on web. We are  using Testcomplet version 8.0 with DOM model.



main()

{

  call function1

  call function2

}



function function1()

{

       if Sys.Process("iexplore").page("*").Document.All.item(134).exists then

         Sys.Process("iexplore").page("*").Document.All.item(134).Click()

       else

         msgbox "Item 134 not existing"

       end if

}





function function2()

{

   msgbox "function2"

}

.......





Regards,

Vinod

3 Replies

  • Hi,



    Before using the Exists property, you should wait for the target object by using the WaitItem method (see the "Waiting for a Process or Window Activation" and "WaitItem Method (Web Objects)" help topics).



    In general, your script is not reliable, because object indexes (those passed to Item) can change. Use Find (see the "Find Method" help topic) to identify objects by properties with stable values (like innerText).
  • Hi,



    My intention of writing above code is execute the else part of “if” statement.


    If item(134) exists then, it is returning “True” and statements under “if”  are executing. If item(134) does not existing , why statements under “else” condition are not executing? System is waiting for item(134) and giving runtime error.  Please provide me one example with code.



    Note: As dev has not given proper names to object, some of the objects don’t have even one constant property.



    Regards,

    Vinod