Exists = false throws an error

Mar 3, 2015 at 2:05 PM
All,

I ran into a problem where we are trying to verify that an element does not exist on a page. We ran into a problem where calling the exists method on something that doesn't exist throws a control not found error. The error is being thrown when the automation searches for the control.

Has anyone seen this problem and developed a solution for it in the context of CUITe? I wanted to update CUITe so that it catches the error and passes back "false" on the exists rather than throwing the error.

Thanks

Jeff
Mar 3, 2015 at 8:53 PM
I should have mentioned one other thing. We are using a Playback failure event handler in our code so that when the control not found error is thrown it automatically goes into this event handler and retries to find the control multiple times, the number being based on the Playback retry settings. So this error plus the retries is adding lots of extra time to our tests, which we want to avoid.

Thanks

Jeff
Jul 30, 2015 at 12:53 PM
It is a relatively simple solution .. You can try the following

bool error = false;
try
{

//In case the CUITe ".exists" method works fine and throws a false
if (!(obj.Exists))
        {
            Assert.IsTrue(false, "The obj does not exist");
        }
}

catch (Exception e)
{
//In case the ".exists" function does not through a false and simply fails//

String trash = e.Message.ToString();
error = true;

return error;


}