Hi,
I am using java-client 3.3.0. and AppiumDriver. When I try to initialize PageFactory (using AppiumFieldDecorator) with MobileElements i am getting following error, but WebElement work fine.
java.lang.IllegalArgumentException: Can not set io.appium.java_client.MobileElement field com.page.holidays.LandingPage.tyHome to org.openqa.selenium.remote.RemoteWebElement$$EnhancerByCGLIB$$86f9ffce
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:741)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:117)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
I understant AppiumDriver is abstract class in this java-client version and both AndroidElement and IOSElement extend MobileElement. Also AppiumDriver has't any specific converter.
But i want to club by IOS & Android pageobjects to eliminate code redundancy hence I have to use AppiumDriver.
One workaround i am working on is type cast WebElement to AndroidElement / IOSElement when ever required but that not the clean way.
Please let me know the root cause and how to fix this this problem. Any Help is much appreciated!!!
Thanks
Rajat