java.lang.IllegalArgumentException: Can not set io.appium.java_client.MobileElement field

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);

App is successfully launching though.


  1. JDK - v 1.8.0
  2. node - v12.16.2
  3. npm - v6.14.4
  4. appium - v1.17.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.


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

You do not have driver init before. Check good example

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.