Page 1 of 1

How to catch ValidationException without failing the test?

Posted: Thu Apr 10, 2014 10:52 am
by IgorDomrev
Sometimes the click fails (Ranorex Bug) .
I want to catch the exception and retry the click without failing the test.
The catch works , but the test fails because the exception was thrown.

HOW TO catch the exception and not fail the test ?
try
{
//click repo item and validate success
}
catch(Ranorex.ValidationException e)
{

Mouse_Click();
}

Re: How to catch ValidationException without failing the test?

Posted: Fri Apr 11, 2014 10:56 am
by mdgairaud
hi,

it fails doing the mouse.click or validating? it's important because the catch isn't the same.

an error doing a click() is catched with a RanorexException and a validation error is catched with a ValidationException.

To avoid this, I always do these steps:
1. Check if item that I want to click over exist
2. Move the mouse over it: Mouse.MoveTo(item)
3. Click on it: Mouse.Click() remember, your mouse it's over the item so you only need to send a click. I didn't know about the bug you comment, but I always liked to move cursor and click instead of click directly over an item (Mouse.Click(item)
4. Validate action

It works for me in 99% percent of executions


hope helps!


regards