appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.19k stars 755 forks source link

java.lang.AbstractMethodError in widget subclasses #2043

Open wazzeps opened 9 months ago

wazzeps commented 9 months ago

Description

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

Environment

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

mykola-mokhnach commented 9 months ago

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

wazzeps commented 9 months ago

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.

mykola-mokhnach commented 9 months ago

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