1

I have a UI component which is JComboBox. I'm trying to invoke method "getSelectedObjects()" which returns an array of Object[]

public Object[] getSelectedObjects() {
  ........
}

In the automation I have written the below code..

NativeObject obj = FruitList.getNativeObject();
com.hp.lft.sdk.internal.DynamicObjectProxy uiObj = obj.invokeMethod("getSelectedObjects", com.hp.lft.sdk.internal.DynamicObjectProxy.class, null);

How can I get the Object[] from uiObj object ?

I'm using LeanFT SDK 14.3.0

user1184100
  • 6,742
  • 29
  • 80
  • 121
  • Why do you have to use the `NativeObject`? Why do you have to invoke the method like that instead of calling it directly? Isn't there a proper LeanFT description you can use to get the element directly? – Adelin Jul 11 '19 at 07:32

1 Answers1

0

I also faced same problem as MicroFocus doesn't provide provide proper documentation of handling NativeObjects or DynamicObjectProxy. It just returns a wrapper object and not able to convert it to any collection type to fetch exact value out of it. After lot of research I found following solution which I hope can help you:

NativeObject obj = FruitList.getNativeObject();
NativeObject uiObj = obj.invokeMethod("getSelectedObjects", NativeObject.class, null);
NativeObject result = uiObj.getItem(NativeObject.class, 0);

'0' mentioned in result variable line can be replaced with an Array. Variable result will give value from NativeObject class based on position like 0,1 etc. You can also write everything in single line like this:

NativeObject result = FruitList.getNativeObject().invokeMethod("getSelectedObjects", NativeObject.class, null).getItem(NativeObject.class, 0);