How to catch ValidationException without failing the test?

Ranorex Spy, Recorder, and Studio.
IgorDomrev
Posts: 1
Joined: Thu Apr 10, 2014 10:46 am

How to catch ValidationException without failing the test?

Post by IgorDomrev » Thu Apr 10, 2014 10:52 am

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();
}

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: How to catch ValidationException without failing the test?

Post by mdgairaud » Fri Apr 11, 2014 10:56 am

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