Forum Discussion

kankele's avatar
kankele
Occasional Contributor
10 years ago

WaitForProperty returning incorrect result

I have a piece of code that works 98% of the time. The other 2% of the time, the WaitForProperty method returns false when I believe it should be returning true. Below is an image captured during debugging (breakpoint has stopped execution just after the line shown below) that shows the property I am looking for is False, but the WaitForProperty method doesn't seem to identify it a being false. The watch list is also shown in the image.

 

DebugImage.png

 

I'm not sure how to proceed to diagnose this issue. Any help would be greatly appreciated.

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    I would make the wait time just a little longer.  We have had a few similar places where the test will fail occasionally and we either add a delay right before it or increase the one that's there just a little and it has solved the problem.

  • So first ask yourself what is/are the conditions that prevent the required state from occuring then create code to handle those conditions. I suggest making the single line statement into a process loop or add a wrapper function that either returns the required object instance or empty if the property fails:

     

    for (var i = 0; i < 10; i++) {
       var r = cellObj.WaitProperty("IsInEditMode", false, 999)
       
       if (r.Exists)
          // continue test code or add code to escape loop;
    }