Calling native methods of an object
Calling native methods of an object
Is it possible to call native methods for custom objects with Ranorex?
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.
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.
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.
Jenö Herget
Ranorex Team
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.
Please write us what this feature can do, we will implement the functionality for a future release.tkondal wrote:I evaluated Mercury QuickTest Pro and noted that it is possible to do something similar.
Jenö Herget
Ranorex Team
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
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
Thank you for this suggestion.
Jenö Herget
Ranorex Team
We support the same functionality for .NET 2.0 objects in V1.0.0.tkondal wrote:with QuictTestPro, it is possible to retrieve all the runtime properties of an object
We will analyse the possibilities and we will support a similar functionality in a future version.tkondal wrote:Concering the Mercury QuickTestPro feature that I was mentioning, it allows one to call an object's function by doing something like...
Jenö Herget
Ranorex Team
-
- Posts: 55
- Joined: Thu Aug 23, 2007 12:00 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
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
-
- Posts: 55
- Joined: Thu Aug 23, 2007 12:00 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#.
Jenö
Ranorex Team
RanorexSpyPro uses this mechanism, but V1.2 supports only the properties of the standard controls and it works only in C#.
You can access only public properties at the moment, but we will check the possibilities.... so i can access e.g. the static string bla
Jenö
Ranorex Team