Calling native methods of an object

Class library usage, coding and language questions.
tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

Calling native methods of an object

Post by tkondal » Thu Nov 16, 2006 3:45 pm

Is it possible to call native methods for custom objects with Ranorex?

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Thu Nov 16, 2006 9:11 pm

I'm sorry but i don't understand what do you exactly mean.
Can you write a sample please.

Jenö Herget
Ranorex Team

tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

Post by tkondal » Fri Nov 17, 2006 5:40 pm

For example,

If I have a custom control with a method DoCustomAction(arg1, arg2) that gets triggered by a mouse click. I want to call that function directly without sending a mouseclick.

My usage would be something like:

Ranorex.ControlShow(hCustomControl);
Ranorex.CallMethod(DoCustomAction, arg1, arg2);

This code would call the DoCustomAction method of the object.


I evaluated Mercury QuickTest Pro and noted thatit is possible to do something similar. I was wondering it was possible to do something like this with Ranorex. I need to do so because I am dealing with a custom combobox that does not obey standard combo box rules. For instance, the function Ranorex.ComboBoxGetItemCount() returns 0 even if the combobox contains items. I wanted to know if I could simply call the object's equivalent of SetComboBoxItem() directly.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Sun Nov 19, 2006 10:11 pm

If we automate an application with Ranorex, then our testcode runs in an other process.
We don't communicate with the objects of the application directly we use some supported mechanism.
Old windows controls can only be automated with windows messages (SendMessage and PostMessage), newer windows controls can be automated also with Active Accessibility or .NET remoting. But we can only automate a control if it supports a mechanism, we cannot call a function of an object directly from an other process. We can do it only, if we embed Ranorex in the application.

If the custom control cannot be automated with SendMessages (ComboBoxGetItemCount works only with messages at the moment), then you can use the element functions, they use active accessibility (see the sample ElementTest.py). Most of the third party user controls can be automated with the element functions. It is also possible that the control supports some mechanism, please check the documentation.
tkondal wrote:I evaluated Mercury QuickTest Pro and noted that it is possible to do something similar.
Please write us what this feature can do, we will implement the functionality for a future release.

Jenö Herget
Ranorex Team

tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

Post by tkondal » Tue Nov 21, 2006 11:26 pm

Thank you for the reply.

Concering the Mercury QuickTestPro feature that I was mentioning, it allows one to call an object's function by doing something like:

GetCustomComboBox("MyCombo").Object.CustomFunction(arg1, arg2, ...)

e.g.
GetCustomComboBox("MyCombo").Object.set_SelectedItem(arg1, arg2, ...)

I also noticed that with QuictTestPro, it is possible to retrieve all the runtime properties of an object. This allows a user to change a property of a GUI object at runtime. It is most likely done with Reflection. Hope this helps you for implementing a nice feature ;)

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Wed Nov 22, 2006 8:40 pm

Thank you for this suggestion.
tkondal wrote:with QuictTestPro, it is possible to retrieve all the runtime properties of an object
We support the same functionality for .NET 2.0 objects in V1.0.0.
tkondal wrote:Concering the Mercury QuickTestPro feature that I was mentioning, it allows one to call an object's function by doing something like...
We will analyse the possibilities and we will support a similar functionality in a future version.

Jenö Herget
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Thu Aug 23, 2007 12:07 pm

I am very interested in this feature too. When will this be available ?

Can I access a Internal object with the (already existing) handle, or in another with reflection ?

Jörg Abelshauser

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Thu Aug 23, 2007 11:32 pm

Please write us what do you exactly want to do.

What do you can from an other process, depends on the control type. It's not possible to call an internal function of an MFC control (you can only send messages if you have the control handle), but it's possible to get/set the properties of a .NET Framework control.
We use this feature in RanorexSpyPro, but we support it only for the .NET languages at the moment.

Please check your controls with RanorexSpy, you can solve most of the problems with the element class.

Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Fri Aug 24, 2007 8:01 am

I want to access public members in a C#-Form-class, e.g.:

public class Form1 : System.Windows.Forms.Form
{
public static string bla = "boing";


Is there a way to access the Instance of the class Form1 via the Ranorex-Form, so i can access e.g. the static string bla ?

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Fri Aug 24, 2007 8:48 pm

We implemented the possibility that you can get and set the public properties of a .NET control from an other process.
RanorexSpyPro uses this mechanism, but V1.2 supports only the properties of the standard controls and it works only in C#.
... so i can access e.g. the static string bla
You can access only public properties at the moment, but we will check the possibilities.

Jenö
Ranorex Team