Execute click() on Ranorex.Core.Element (C#)

Class library usage, coding and language questions.
Posts: 10
Joined: Tue May 09, 2017 4:15 pm

Execute click() on Ranorex.Core.Element (C#)

Post by lawrence » Tue May 09, 2017 4:48 pm

Hi all

new to Ranorex and new to C#, hence I've got the following question:
When I pass a repository item into a user code method as Ranorex.Adapter I can use method Click() to click that item.

In my user code method I however ended up with objects of type Ranorex.Core.Element which I want to click.

Let's consider the following example:

Code: Select all

public static void clickParents(Ranorex.Adapter child){
      IList<Element> allChildren = child.Element.Parent.Children;
      foreach(var childElem in allChildren){
            childElem.<insert correct method and args for clicking each child>;
1. Is there a way to execute a click on an object of type Ranorex.Core.Element?
2. Or alternatively: how do I get an Adapter from the respective Ranorex.Core.Element?
3. Or alternatively: how do I get the parent of an Adapter without ending up with Elements?

Note: there's reason why I don't just pass in the parent to the user code function which is related to the GUI structure of the application under test.

It's not obvious to me how those two classes are related, so if you'd like to shed some light on that, please go ahead...

Many thanks for the help


Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: Execute click() on Ranorex.Core.Element (C#)

Post by ahoisl » Tue May 09, 2017 7:23 pm

You have two options here, either create an adapter for the element or use a Mouse method taking an element/adapter as argument:
new Unknown(childElem).Click();
// or
I would suggest to use the Adapter.Click method.

I'll add a feature request to add a "Parent" property to the Adapter class.

Ranorex Team