java-client icon indicating copy to clipboard operation
java-client copied to clipboard

java.lang.AbstractMethodError in widget subclasses

Open wazzeps opened this issue 2 years ago • 3 comments

Description

Since java-client 8.6.0 calling the implementation of abstract methods in widget subclasses results in throwing exception java.lang.AbstractMethodError.

Environment

  • Java-client 8.6.0
  • Appium 2.1.3
  • Java 11

Code To Reproduce Issue [ Good To Have ]

Widgets:

public abstract class Tab extends Widget {

    protected Tab(WebElement element) {
        super(element);
    }

    public abstract boolean isSelected();
}
public class AndroidTab extends Tab {

    protected AndroidTab(WebElement element) {
        super(element);
    }

    @Override
    public boolean isSelected() {
        return getWrappedElement().isSelected();
    }
}

Screen:

@AndroidFindBy(id = "loginTab")
@OverrideWidget(androidUIAutomator = AndroidTab.class, iOSXCUITAutomation = IosTab.class)
private Tab loginTab;

public boolean isLoginTabSelected() {
    return loginTab.isSelected();
}

Exception Stacktraces

java.lang.AbstractMethodError: Receiver class autotests.component.tab.Tab$ByteBuddy$WYq3RqHe does not define or inherit an implementation of the resolved method 'abstract boolean isSelected()' of abstract class autotests.component.tab.Tab. at autotests.screen.authorization.LoginScreen.isLoginTabSelected

wazzeps avatar Oct 13 '23 12:10 wazzeps

I am not sure this was ever possible: https://github.com/appium/java-client/blob/master/docs/Page-objects.md#what-if-interaction-with-a-widget-has-special-details-for-each-used-platform-but-the-same-at-high-level

mykola-mokhnach avatar Oct 13 '23 14:10 mykola-mokhnach

This worked correctly in version 8.5.0. And in version 8.5.1 there was a bug in a similar code example. You fixed it here #1937.

wazzeps avatar Oct 13 '23 14:10 wazzeps

I would still try to use approach adviced by the documentation. I don't know what else I could do there

mykola-mokhnach avatar Oct 13 '23 15:10 mykola-mokhnach