Forum Discussion

ScorpionSoft's avatar
ScorpionSoft
New Contributor
15 years ago

Waiting for WPF Objects without WaitWPFObject

In the project that I'm testing, I need to wait for a WPF object that may not be available for several minutes as the system does its processing. If I use WaitWPFObject and set the timeout to more than about 30000 milliseconds, it will not wait the whole time.



The semi-solution that I have come accross is to put the WaitWPFObject call in a DO loop and check for it to exist and be visible on screen. The only problem with this is that if the WPF object doesn't exist, it will write an error to the log, which I don't want.



Is there any way to reference a WPF Object from WaitChild or Wait Window, or cause WaitWPFObject not to write an error to the log?

6 Replies

  • Oh..God.. this is exactly Im looking for. Please post the solution if you found a workaround.

    Thanks..
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Brent,



    Wait...() functions should not post errors to the log if the object was not found as this is what they were designed for: try to get the reference to the object that may not exist.

    Can you post here the code snippet that posts an error to the log?
  • Hi Alexi,

    If I run the following code and it times out, it writes object not found errors to the logs. The screen that I'm waiting for takes a variable amount of time to pop up, depending on the system, so it's something that I need to loop a wait object for.



    i = 0

    Do 

        Set w = setup.WPFObject("HwndSource: win_SubscriptionInfo", "Setup").WPFObject("win_SubscriptionInfo", "Setup", 1).WaitWPFObject("DocumentRoot", 45000)

        i = i + 1

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

    Set grid = setup.WPFObject("HwndSource: win_SubscriptionInfo", "Setup").WPFObject("win_SubscriptionInfo", "Setup", 1).WPFObject("DocumentRoot")

     
  • Hi Brent,



    The error seems to come from the line which follows the loop. You need to remove this line as you already have the target object at this point, and there's no need to obtain it again. Just check 'w.Exists' after your loop and use 'w' if it's True.

  • pabramowitsch's avatar
    pabramowitsch
    Occasional Contributor
    I have the same problem with waitChild in a Java App.     It does not always wait.  Looking at what is inside waitChild, it is just a loop checking for child and then waiting.  My suspicion is that wait drops through because it has in fact found the window (perhaps its not completely populated) but then other objects on that window are not yet found.



    Strange thing is that sometimes, when I run the application once outside of test complete, it will then respond properly inside a playback script.



    -p



  • Hi,



    You need to use methods specific to Java applications (WaitSwingObject, WaitSWTObject, etc.), not WaitChild. If you are using Name Mapping, obtain your object with WaitAliasChild.