iOSElements not compatible with Page Factory pattern?

I haven’t been able to find any info on google or stackoverflow or even here. Basically, Page Factory does not seem to accept iOSElements and I am unable to cast any WebElements to iOSElements (to use, for example, setValue() over sendKeys() to optimize test run time).

I get an error like this:

java.lang.IllegalArgumentException: Can not set io.appium.java_client.ios.IOSElement field screens.LoginScreen.signInEmail to org.openqa.selenium.remote.RemoteWebElement$$EnhancerByCGLIB$$62bef779

My code is something simple, like this:

public class LoginScreen {

private WebDriver driver;

@FindBy(id = “validselector”)
public IOSElement signInEmail;

@FindBy(id = “validselector”)
public IOSElement signInPassword;

@FindBy(id = “validselector”)
public IOSElement loginButton;

public LoginScreen(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);

public SomeOtherObject login(String email, String password) {
return new SomeOtherObject(driver);

My driver is set up to just be a remote driver in a separate file, as such:
driver = new RemoteWebDriver(new URL(“”), capabilities);

Is there a way to implement a Page Factory design using iOSElements without having to make a custom Page Factory (I’m not sure how to approach such a task)? I’m confused about implementation.

Nevermind, I just figured it out after much finagling:

I require an IOSDriver, not a WebDriver.

this.driver = new IOSDriver(new URL(“”), capabilities);

This accepts IOSElements when passed to PageFactory.initElements();

Instead of using findBy for IOS elements, always use @iOSFindBy.

1 Like