I'm using the unmanaged windows automation api from C# to automate a third party application. I use this to select a list item in list A in the third part application. This causes the third party application to change the list items in list B. List B items are logically child elements (not in terms of the automation tree!) of the select item in list A. This takes an indeterminate amount of time. Is there a callback or property etc I can use to check that this update has completed?
-
I dont think there is - I think its one of those situations where you just need to poll the value of the window until it changes. – PhillipH Feb 06 '18 at 21:00
-
@PhillipH hmm. It is possible for list B to be empty before and after the update :-( – Tim Galvin Feb 06 '18 at 21:02
-
If the application exposes some kind of MVVM state machine, then you can use that, but most dont, and those that expose the control state for screen-reader applications dont tend to have an "I have finished changing" signal. Horrible though it is it might be an occasion for the Thread.Sleep() – PhillipH Feb 06 '18 at 21:37
1 Answers
You would need to implement some type of retry condition and provide it with a Predicate
that it can evaluate. I made and open source project called Mulligan which encapsulates the logic that TestStack.White and FlaUI use to allow for retrying.
The reason I made this framework is so that I could gather more information on when retries are occurring but tests succeed (meaning the predicate is incorrect) but the logic otherwise is very similar to what the previously mentioned frameworks are doing.
For lists what I have generally done is add a very short retry for if the grid has no elements in it. Then I get the count of the elements, then add new things to the list then validate the count is the previous count + added elements. I started doing it this way because we had a scenario where I was only checking for the new elements but we had introduced a bug where all elements were missing except the new element... Also for some of our lists in our application we have an overlay loading spinner that I wait till it is done running to start the previously mentioned wait to get the count.

- 1,522
- 1
- 16
- 42