IOSElements contain the .setValue() method, which types much faster than sendKeys(). However, if I set my elements (using @FindBy annotations) to IOSElement rather than WebElement, PageFactory will return an error:
java.lang.IllegalArgumentException: Can not set io.appium.java_client.ios.IOSElement field screens.LoginScreen.signInEmail to org.openqa.selenium.remote.RemoteWebElement$$EnhancerByCGLIB$$62bef779
Additionally, I cannot cast WebElements to IOSElements, as that will return an error from the JVM as well (cannot cast).
Is there a way to initialize IOSElements using the PageFactory design? My sample code is as follows:
public class LoginScreen {
private WebDriver driver;
@FindBy(className = "UIATextField")
public IOSElement signInEmail;
@FindBy(className = "UIASecureTextField")
public IOSElement signInPassword;
@FindBy(id = "Log in")
public IOSElement loginButton;
@FindBy(id = "Forgot your password?")
public IOSElement forgotPasswordButton;
public LoginScreen(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
public SomeOtherObject login(String email, String password) {
signInEmail.setValue(email);
signInPassword.setValue(password);
loginButton.click();
return new SomeOtherObject(driver);
}
}