#320 fix by TikhomirovSergey · Pull Request #327 · appium/java-client

Changes:

  • 320 fix. The Widget.getSelfReference() was added. This method allows to extract a real widget-object from inside a proxy at some extraordinary situations.

  • test modification

This change is the addition to features whis heve been implemented here: #267. There was a problem:

This use case has some restrictions;
...

  • for now it is not possible to
  import io.appium.java_client.pagefactory.OverrideWidget;
  ...

  //above is the other field declaration
  @OverrideWidget(html = UsersWidgetForHtml.class, 
  androidUIAutomator = UsersWidgetForAndroid.class, iOSUIAutomation = UsersWidgetForIOS .class)
  DefaultAbstractUsersWidget widget;

  //below is the other field/method declaration

  //user's code
  ((UsersWidgetForAndroid) widget).doSpecialWorkForAndroing()

I think that this problem will be resolved next time.

So this commit resolves this issie and related problems this way:

  import io.appium.java_client.pagefactory.OverrideWidget;
  ...

  //above is the other field declaration
  @OverrideWidget(html = UsersWidgetForHtml.class, 
  androidUIAutomator = UsersWidgetForAndroid.class, iOSUIAutomation = UsersWidgetForIOS .class)
  DefaultAbstractUsersWidget widget;

  //below is the other field/method declaration

  //user's code
  ((UsersWidgetForAndroid) widget.getSelfReference()).doSpecialWorkForAndroing()