Unable to perform an action on the element.
Getting “java.lang.IllegalArgumentException: Can not set io.appium.java_client.MobileElement field”
I’m using the following constructor
public BaseTest() { //Constructor
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
System.out.println("print");
}
App is successfully launching though.
Configuration:
- JDK - v 1.8.0
- node - v12.16.2
- npm - v6.14.4
- appium - v1.17.0
Dependencies:
io.appium
java-client
7.2.0
it should be:
PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ofSeconds(sec)), this);
where “sec” is some sec time. With your example it will take default = 1 sec. But still should work. We need more code example of your project.
2 Likes
Hi @Aleksei,
Tried it, but getting this exception
The constructor AppiumFieldDecorator(AppiumDriver, int, TimeUnit) is undefined
Here is the code as recommended by you. Still not working.
public class BaseTest {
protected AppiumDriver<MobileElement> driver;
protected Properties props;
InputStream inputStream;
public BaseTest() { //Constructor
PageFactory.initElements(new AppiumFieldDecorator(driver, 5, TimeUnit.SECONDS), this);
}
1 Like
Thanks @Aleksei
This worked for me!!
Defined the driver as “static”
public BaseTest() {
PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ofSeconds(10)), this);
}
Thank you Aleski.
My issue was fixed using your code.