Cannot Create Simple Ranorex Controls

Ranorex Studio, Spy, Recorder, and Driver.
User avatar
orko
Posts: 9
Joined: Wed Sep 14, 2016 9:28 pm
Location: Bartlesville, OK

Cannot Create Simple Ranorex Controls

Post by orko » Fri Oct 14, 2016 5:17 pm

Hello there,

I am not able to create simple Ranorex Controls in my user code.

I took the examples from here:
http://www.ranorex.com/support/user-gui ... apter.html and created a simple Winforms app in C#. Then a very basic project in Ranorex 6.1.0 to get a grasp on how delegates work in Ranorex (using invokeremotely). I didn't get very far however because before I was able to try out delegates I came across an issue where a simple Winforms control (Button, Checkbox, TextBox) was not able to be transformed into a Ranorex Control.

I keep getting the following when I execute this project:
The element does not support the required capability 'control'.

at Ranorex.Adapter..ctor(Element element) at testDelegateSimple.Class1.GoDoIt() at testDelegateSimple.Recording1.Ranorex.Core.Testing.ITestModule.Run() at Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext)
What am I doing wrong? I'm executing both of these applications as the same user (admin rights). They are both compiled with the same.Net versions, platforms and targets.

Do these execute for you, or do they generate the same exception?
You do not have the required permissions to view the files attached to this post.

User avatar
orko
Posts: 9
Joined: Wed Sep 14, 2016 9:28 pm
Location: Bartlesville, OK

Re: Cannot Create Simple Ranorex Controls

Post by orko » Fri Oct 14, 2016 5:43 pm

Please note that the Ranorex project is saved as compiling to x86/Debug, but I've tried all possible combinations on both the app and Ranorex side to get this to work. I'm at a point now where I've tried to repair my Visual Studio 2015 and Ranorex installations, and I'm still having that exception. Maybe I'm missing something basic in my understanding of the Ranorex Control?

After I can actually invoke remotely, I'm planning on using delegates to get the return of a non-serializable return parameter in my AUT by passing a string back from the delegate. Have to get past this hurdle first though, so I can use the invokeremote method.

Thanks for your time,
Joe

User avatar
orko
Posts: 9
Joined: Wed Sep 14, 2016 9:28 pm
Location: Bartlesville, OK

Re: Cannot Create Simple Ranorex Controls

Post by orko » Fri Oct 14, 2016 6:50 pm

Here's the code from within the Ranorex project I attached above:

Code: Select all

... snip ...
Ranorex.Button button1 = repo.RanorexTest.Button1.GetPath().ToString();
Ranorex.Control wButton1 = new Ranorex.Control(button1); // <--- Exception thrown here

name = (string)wButton1.InvokeRemotely(IR_GetName, "ButtonTest");
Report.Info("button=" + name);
...
Then I have the IR_GetName() method, which isn't even getting called due to the exception being thrown in the "new Ranorex.Control()" line.

Code: Select all

public static object IR_GetName(System.Windows.Forms.Control control, object appendText){
	System.Windows.Forms.Button b = control as System.Windows.Forms.Button;
	appendText = (appendText == null) ? "": appendText;
	
	string ret = String.Format("{0}-{1}", b.Name, appendText);
	
	return ret;
}

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Cannot Create Simple Ranorex Controls

Post by Support Team » Mon Oct 17, 2016 1:58 pm

Hello Joe,

The issue is that you access the wrong UI element which doesn't support the capability 'control'. It seems like you disabled the MSAA option 'Filter Elements'. As a consequence, the corresponding button is recognized twice (via the WinForms plugin and MSAA).
button_msaa.png
I would suggest using the path "/form[@title='Form1']//button[@controlname='button1']" that points to the correct element. The same is true for the other UI elements. After changing the RanoreXPath for the button, the InvokeRemotely method could be executed successfully.

I hope this information will help you.

Sincerely,
Johannes
You do not have the required permissions to view the files attached to this post.

User avatar
orko
Posts: 9
Joined: Wed Sep 14, 2016 9:28 pm
Location: Bartlesville, OK

Re: Cannot Create Simple Ranorex Controls

Post by orko » Tue Oct 18, 2016 2:18 am

That was it! Thank you very much for showing me that, it was driving me nuts :-)

It was the "Filter Windows Forms Elements" setting that needed to be toggled to "True". I must have set it to false by mistake.