Page 1 of 1

How do Ranorex access the elements of the array in Java?

Posted: Fri Apr 24, 2015 12:38 pm
by pramilas
Hi,

The application under test have a table in the application and its row contains value by default.
Based on various parameters, the column contains different values. In one of the cell value , it returns an array of objects.
When I try to retrieve "Text" property of these cells I always get "[Lcom.ambientcorp.nms.common.type.ID;@65031a" values.
The cell value is an array of class instances and this returns a value indicating that an array is returned [Lcom.ambientcorp.nms.common.type.ID;@65031a

When a Java array comes back how do Ranorex access the elements of the array?

Regards,
Pramila

Re: How do Ranorex access the elements of the array in Java?

Posted: Fri Apr 24, 2015 1:07 pm
by odklizec
Hi,

Could you please post a Ranorex snapshot (or send it to [email protected]) of the table/element in question?

Also, what exactly do you want to do with the obtained "array"? Validate just one (or more) of its values?

It should be possible to obtain specific elements of that "array" by using GetValue action combined with carefully constructed regular expression. Check this user guide paragraph...
http://www.ranorex.com/support/user-gui ... html#c4090

Another possibility might be to use a custom code to parse the array and do whatever you want with the individual array elements.

Re: How do Ranorex access the elements of the array in Java?

Posted: Fri Apr 24, 2015 2:10 pm
by krstcs
My primary SUT is a Java POS application. I have similar issues.

The problem isn't that an array is returned. The problem is that a STRING REPRESENTATION of the ARRAY POINTER is returned. This is typical with a Java table in Swing. If you developers don't set up the cell renderer the right way, Ranorex won't be able to see the actual value. Note: When I say "right way" here I don't mean that the devs did anything wrong with the way they did it, just that Java renders table cells strangely if the developer doesn't change it.

You will probably need to have your developers change the table to include the needed information if you want to get the actual values from inside the array.

Re: How do Ranorex access the elements of the array in Java?

Posted: Fri Apr 24, 2015 2:49 pm
by pramilas
please find the Ranorex snapshot of the table/element in question.
Thanks for the response.

Re: How do Ranorex access the elements of the array in Java?

Posted: Fri Apr 24, 2015 3:04 pm
by krstcs
Yeah, after looking at the snapshot, it's as I said, Ranorex is reading the array pointer instead of the array items. Your developers implemented the renderer to display the array as a comma separated list, which means Ranorex can't see the actual string text because it only sees the cell and not the renderer. You will need to have the developers change the cell to include the string in an attribute or something similar.