Skip to content

Failed to initialize object with generic type via AppiumFieldDecorator #368

Closed
@SButterfly

Description

@SButterfly

Hello,
when I want to use pages with generic types, I get those:

Objects:

public class TempLoginPage<T> {

    public List<T> items;

    public List<T> getItems() {
        return items;
    }
}

public class LoginPage extends TempLoginPage<Object> {

    @iOSFindBy(uiAutomator = ".buttons()['Login']")
    public WebElement loginButton;
}

// main
PageFactory.initElements(new AppiumFieldDecorator(getDriver()), new LoginPage());

Crashes with:

java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
    at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorateWidget(AppiumFieldDecorator.java:185)
    at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:160)
    at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113)
    at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
    at 
    ... 47 more

I'm using 3.3.0 java client

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions