In coded ui there is a way to wait for a control to exist using UITestControl.WaitForControlExist(waitTime);
. Is there a way to wait for a control to not exist?
The best way I could think of is to create an extension method like this:
public static bool WaitForControlClickable(this UITestControl control, int waitTime = 10000)
{
Point p;
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (stopwatch.ElapsedMilliseconds < waitTime)
{
if (control.TryGetClickablePoint(out p))
{
return true;
}
Thread.Sleep(500);
}
return control.TryGetClickablePoint(out p);
}
Is there a better way of doing this? Also I am looking for a way to do the opposite.
The ' |= ' symbol is the bitwise OR assignment operator.
The ~ operator in C++ (and other C-like languages like C and Java) performs a bitwise NOT operation - all the 1 bits in the operand are set to 0 and all the 0 bits in the operand are set to 1. In other words, it creates the complement of the original number.
C operators are one of the features in C which has symbols that can be used to perform mathematical, relational, bitwise, conditional, or logical manipulations. The C programming language has a lot of built-in operators to perform various tasks as per the need of the program.
In C/C++, the # sign marks preprocessor directives. If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more.
So what WaitForControlExists actually does is to call the public WaitForControlPropertyEqual, something like:
return this.WaitForControlPropertyEqual(UITestControl.PropertyNames.Exists, true, timeout);
Your helper can instead call:
public bool WaitForControlPropertyNotEqual(string propertyName,
object propertyValue, int millisecondsTimeout)
Also, as Kek points out, there is a WaitForControlNotExist public method.
Note that they all seem to be using the same helper (also public):
public static bool WaitForCondition<T>(T conditionContext, Predicate<T> conditionEvaluator, int millisecondsTimeout)
this helper essentially does a Thread.Sleep on the current thread, pretty much as you do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With