I'm having trouble understanding how InvokeMethod and GetPropertyValue works.
I'm testing on 3rd party controls and enjoy the feature of calling custom methods and properties. Nevertheless I've run into some problems - some methods/properties simply return null. The reason for this is unclear to me and the Ranorex documentation does not provide much help.
I'm calling a property named Items but it returns null. I've set ErrorAsException to true but I get no exception - which may indicate that the property is actually null (even though I don't think it is). But if I try to call it with "get_Items" using InvokeMethod I get an InvalidOperationException with the message "The control does no longer exist." but it does. I can click it, see it and check other properties just fine.
Some information would be appreciated. Thanks for your time.
Using InvokeMethod and GetPropertyValue
-
- Posts: 44
- Joined: Fri Oct 26, 2007 1:18 pm
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
The problem is that these methods cross process boundaries and therefore the parameters and return values need to be serializable, i.e. transferable between process boundaries. The GetPropertyValue and InvokeMethod methods will return null if the returned value is not serializable. All primitive types (like int, double, string, …) are serializable and all classes marked with the Serializable attribute. For all other return types you need to provide some way to make the wanted data serializable.
With Ranorex 1.4 the only way was to provide a helper method in the control you want the data from. However, that often implies a change request to the control developer which often takes some time and sometimes isn't even possible.
That's why with Ranorex 1.5 we introduced a new way that does not imply a code change to the automated control: the Control.InvokeRemotely method. Using the Control.InvokeRemotely method one can define a delegate in the Ranorex code that is executed in the process of the automated control. This delegate should collect the wanted data and needs to return it in a serializable format (e.g. as a list of strings or integers).
I will write a Ranorex blog entry next week that will provide an example on how to use the Control.InvokeRemotely method - just in case the API documentation is not clear enough
Regards,
Alex
Ranorex Support Team
With Ranorex 1.4 the only way was to provide a helper method in the control you want the data from. However, that often implies a change request to the control developer which often takes some time and sometimes isn't even possible.
That's why with Ranorex 1.5 we introduced a new way that does not imply a code change to the automated control: the Control.InvokeRemotely method. Using the Control.InvokeRemotely method one can define a delegate in the Ranorex code that is executed in the process of the automated control. This delegate should collect the wanted data and needs to return it in a serializable format (e.g. as a list of strings or integers).
I will write a Ranorex blog entry next week that will provide an example on how to use the Control.InvokeRemotely method - just in case the API documentation is not clear enough
Regards,
Alex
Ranorex Support Team
-
- Posts: 44
- Joined: Fri Oct 26, 2007 1:18 pm
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
I just finished the blog post, you can find it here:
http://www.ranorex.com/blog/transfering ... et-control
Alex
Ranorex Support Team
http://www.ranorex.com/blog/transfering ... et-control
Alex
Ranorex Support Team
-
- Posts: 44
- Joined: Fri Oct 26, 2007 1:18 pm