Search code examples
c#automated-testscoded-ui-tests

coded ui control polling instead of wait for control exists


I have coded ui tests with a lot of WaitForControlExists in them. This causes my tests to run slow.

Basically if Playback.PlaybackSettings.SearchTimeout = 30000; and I have uicontrol.WaitForControlExists() it takes 30 seconds to get feedback from the method, even if the control is shown after 1 second.

Now I want to find out if there's a way to exit the WaitForControlExist as soon as the control exists? Say, I "Poll the Control Exists" instead of "Wait For Control Exists".

I will set the poll timer to 1 second. Meaning I check every second if the control exists. If it SHOWS after 2 seconds (or whatever less than 30 seconds) return true and stop Polling, if not keep trying every second when its been 30 seconds, quit and return false.


Solution

  • use uiControl.WaitForControlCondition(control => control.Condition,timeout);

    With this you can mix and match the control conditions that you want to be met before proceeding with the execution.

    The most useful one for me is the State of the control and the styles. have fun :)