Forum Discussion

TESTUS's avatar
TESTUS
Contributor
11 years ago
Solved

w.VisibleOnScreen does not exist

Hello SmartBear Support,



I am using the attached code snippet from your [support site].






  1. Sub Test


  2.   i = 0


  3.   Set p = TestedApps.myApp.Run


  4.   Do


  5.     Set w = p.WaitWindow("ThunderRT6FormDC", "myApp(V?.*?.*?)", -1, 60000)


  6.     i = i + 1


  7.   Loop Until (w.Exists And w.VisibleOnScreen) Or (i > 10)


  8.  


  9.   If Not (w.Exists And w.VisibleOnScreen) Then


  10.     Log.Warning "Window not found."


  11.   Else


  12.     Log.Message "Window was found."


  13.   End If


  14. End Sub



About 2 out of 9 times an error occurs at line 7 and 9. It says:


  • "The object does not exist. See Additional Information for details."


At the "Additional Info" tab it says:


  • "You are trying to call the "VisibleOnScreen" method or property of the "myApp (V?.*?.*?)" object that does not exist."


I ran the same script 9 times in a row and got the error at run 1 and 5. So the error seems to appear randomly.



Please help, thanks.
  • Hi Oliver,



    From what you describe, I would not sure  that p is well defined when the loop starts.



    Just before the WaitWindow loop and after the Set p = TestApps.myApp.Run I would add



    Set p = WaitProcess(processName,20000). The timeout value can be very hight as the function returns as soon as it gets a grip on the process.



    It's worth a try ;-)



    Sincerely

    Simon Glet











7 Replies

  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Hi Oliver,



    From what you describe, I would not sure  that p is well defined when the loop starts.



    Just before the WaitWindow loop and after the Set p = TestApps.myApp.Run I would add



    Set p = WaitProcess(processName,20000). The timeout value can be very hight as the function returns as soon as it gets a grip on the process.



    It's worth a try ;-)



    Sincerely

    Simon Glet











  • sastowe's avatar
    sastowe
    Super Contributor
    Line 7 is



     Loop Until (w.Exists And w.VisibleOnScreen) Or (i > 10)



    The Until cannot evaluate the latter half of the expression if w does not existi



    Evaluate w.Exists FIRST then look to see if once it exists it is visible on screen.
  • This article does not help me.

    Since I do not adress a mapped object most of the possible causes do not apply.



    There are three other possible causes:






    and





    • The object has not been created by the time TestComplete tries to obtain it.




    seem very unlikely since I am waiting for the object/process in line 5 by using the WaitWindow command.






    is the last possible cause that does not apply either. The process did not freeze, also the Freeze Diagnostic properties of my test project are set accordingly.


     


  • Hi Simon,



    I added the line you supposed last evening and let the script run a few times overnight.

    All runs were successful.



    Thank you very much!
  • Okey, forget what I just said...

    I just ran the script once more and the error occured again. It seems like the successful runs were pure luck.



    Is there a way to "unaccept" an answer?
  • simon_glet's avatar
    simon_glet
    Regular Contributor
    Oliver,



    I am sorry it didn't workout for you. In any case getting hold of  UI elements at application startup can be tricky so do not assume anything and check every object that you are working with.



    After looking around, I didn't find a way to "unanswer" my reply. This might be a task for the forum administrator ;-)



    Sincerely