title: Can't get Page Object Model to work with Appium, Serenity, Selenium, Java
body: <p>I am writing a selenium test automation framework using Java with Appium and Serenity.</p>
  
  <p>I am having problems creating Page Object Model.</p>
  
  <p>My page class looks like this:</p>
  
  <pre><code>public class MattVerifyPage extends PageObject{
  private AppiumDriver driver;
  
  public MattVerifyPage(AppiumDriver driver) {
      this.driver = driver;
      PageFactory.initElements(new AppiumFieldDecorator(driver), this);
  }
  
  
  @AndroidFindBy(xpath = "Androidxpath")
  @iOSFindBy(xpath = "iOSxpath")
  public MobileElement verifyTitle ;
  
  
  public void verifyTitle(String expectedTitle){
  
      String actualTitle =verifyTitle.getText();
  }
  </code></pre>
  
  <p>In my test step file the page is instantiated using this code:</p>
  
  <pre><code>MattVerifyPage VerifyPage = new MattVerifyPage(driver);
  </code></pre>
  
  <p>However, when I run the test I get the error shown below. </p>
  
  <pre><code>java.lang.IllegalArgumentException: Can not set io.appium.java_client.MobileElement field com.xxx.test.pages.MattVerifyPage.verifyTitle to com.sun.proxy.$Proxy19
  at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
  at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
  at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
  at java.lang.reflect.Field.set(Field.java:764)
  at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:117)
  at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
  at net.thucydides.core.annotations.locators.SmartElementProxyCreator.lambda$new$3(SmartElementProxyCreator.java:37)
  at net.thucydides.core.annotations.locators.SmartElementProxyCreator.proxyElements(SmartElementProxyCreator.java:48)
  at net.thucydides.core.webdriver.DefaultPageObjectInitialiser.apply(DefaultPageObjectInitialiser.java:21)
  at net.serenitybdd.core.pages.PageObject.setDriver(PageObject.java:151)
  at net.serenitybdd.core.pages.PageObject.setDriver(PageObject.java:155)
  at net.thucydides.core.steps.PageObjectDependencyInjector.updatePageObject(PageObjectDependencyInjector.java:69)
  at net.thucydides.core.steps.PageObjectDependencyInjector.instantiatePageObjectIfNotAssigned(PageObjectDependencyInjector.java:59)
  at net.thucydides.core.steps.PageObjectDependencyInjector.injectDependenciesInto(PageObjectDependencyInjector.java:33)
  at net.serenitybdd.core.Serenity.injectDependenciesInto(Serenity.java:61)
  at net.serenitybdd.core.Serenity.initializeWithNoStepListener(Serenity.java:102)
  at cucumber.runtime.SerenityObjectFactory.newInstance(SerenityObjectFactory.java:68)
  at cucumber.runtime.SerenityObjectFactory.cacheNewInstance(SerenityObjectFactory.java:51)
  at cucumber.runtime.SerenityObjectFactory.getInstance(SerenityObjectFactory.java:41)
  at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:37)
  at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:40)
  at cucumber.api.TestStep.executeStep(TestStep.java:102)
  at cucumber.api.TestStep.run(TestStep.java:83)
  at cucumber.api.TestCase.run(TestCase.java:58)
  at cucumber.runner.Runner.runPickle(Runner.java:80)
  at cucumber.runtime.Runtime.runFeature(Runtime.java:119)
  at cucumber.runtime.Runtime.run(Runtime.java:104)
  at cucumber.api.cli.Main.run(Main.java:36)
  at cucumber.api.cli.Main.main(Main.java:18)
  </code></pre>