Ranorex.Adapter.Click exceptions

Ask general questions here.
Ben Jones
Posts: 11
Joined: Mon Oct 21, 2019 10:37 am

Ranorex.Adapter.Click exceptions

Post by Ben Jones » Fri Jan 29, 2021 5:30 pm

Hi,

I'm using ranorex 9.3.3.

I have been trying to find out what (if any) exceptions are thrown by
Ranorex.Adapter.Click()
I have checked here: https://www.ranorex.com/Documentation/R ... _Click.htm but nothing is really explained. I have also tried using ILSpy but no information is there either.

What I would like to do is catch the exception thrown when Click() fails to click on the adapter its acting on. Mainly because the adapter for he repoIteminfo element might not exist:
try 
{
window.Click();
} 
catch (Exception)
{
throw;
}
The code above is to be used in some user code method that asks for a repository item to be passed to the variable "window"

User avatar
Stub
Posts: 425
Joined: Fri Jul 15, 2016 1:35 pm

Re: Ranorex.Adapter.Click exceptions

Post by Stub » Mon Feb 01, 2021 9:18 am

Have you looked at the documentation for the RanorexException class? There are a number of child classes which may be of interest.

When something may not exist I usually test for its existence by searching for a short period via RepoItemInfo.Exists(). When something must exist to continue I use Validate.Exists(). I haven't tended to catch Ranorex Exceptions all that often. I once had to do something along the lines of:

Code: Select all

            catch (Ranorex.RanorexException exc)
            {
                if (exc.InnerException is Ranorex.ElementNotFoundException)
But that appears to have been related to a difference between Ranorex v8.2.1 and v8.3.3 by the looks of the code. So not something I've used much myself.