I have the following code:
package pages;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
public class TestPage {
public TestPage(AppiumDriver<?> driver) {
PageFactory.initElements(driver, this);
}
@FindBy(id = "example")
public MobileElement myElement;
}
and from another file I’m trying to do something like this:
AppiumDriver<?> driver = MobileDriverFactory.getDriver();
TestPage testPage= new TestPage(driver);
testPage.myElement.click()
but I receive the following error:
java.lang.IllegalArgumentException: Can not set io.appium.java_client.MobileElement field pages.TestPage.myElement to com.sun.proxy.$Proxy16
I also tried to us the PageFactory
with the decorator:
PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ofSeconds(20)), this);
but I receive another different error:
java.lang.NoClassDefFoundError: org/objectweb/asm/Type
How can I solve it?