appium / appium/java-client

Unable to initialize custom MobileElement block with AppiumFieldDecorator

Open
#1,068 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

The problem

Have such page object:
public class SomeOtherScreen extends BaseScreen {
@AndroidFindBy(xpath = "some locator")
private MyElementsBlock myElementsBlock; //details of this type described below

@AndroidFindBy(xpath = "some locator")
private MobileElement loginButton;

public SomeOtherScreen(AppiumDriver<MobileElement> driver) {
    super(driver);
}

//some other methods to perform actions on screen

}
At the same time MyelementsBlock has nex structure:

public class MyElementsBlock extends MobileElement {
@AndroidFindBy(xpath = "some locator")
private List someOtherBlocksList;

@AndroidFindBy(xpath = "some locator")
private List<MobileElement> mobileElementsList;

}

Elements initialization:

public abstract class BaseScreen {
protected AppiumDriver driver;

public BaseScreen(AppiumDriver<MobileElement> driver) {
    this.driver = driver;
    PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}

}

During running in fails on "PageFactory.initElements(new AppiumFieldDecorator(driver), this)" with next message:
java.lang.IllegalArgumentException: Can not set com.application.blocks.MyElementsBlock field com.application.screens.SomeOtherScreen.myElementsBlock to io.appium.java_client.android.AndroidElement$$EnhancerByCGLIB$$b598166c

Environment

  • Appium version (or git revision) that exhibits the issue: 1.71
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: Windows 10
  • Node.js version (unless using Appium.app|exe):
  • Mobile platform/version under test: Android 5.1
  • Real device or emulator/simulator: Genymotion (Samsung Galaxy S6)
  • Appium CLI or Appium.app|exe:

Any ideas?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the BaseScreen constructor and the PageFactory.initElements(new AppiumFieldDecorator(driver), this) call shown in the issue. Trace how AppiumFieldDecorator handles the MyElementsBlock field and compare that with the MobileElement type expected by the field. Done means the example initializes without IllegalArgumentException, including its declared nested fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.