appium / appium/java-client

Pagefactory AndroidFindBy not taking effect on appium java 7.3.0

Open
#1,275 8 comments 1 reaction 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

Page Factory, Android Find By locator helper not initializing locators correctly in java client 7.3.0, works fine on 7.2.0.

Environment

Appium Java Client : 7.3.0
JDK : Open JDK 13
Node: v10.17.0
Run time: Node Server (Haven't tested on appium desktop)
Windows 7
Android 7
Emulator

Code To Reproduce Issue [ Good To Have ]

public class HomeScreen {

  public HomeScreen(AppiumDriver appiumDriver) {
    PageFactory.initElements(new AppiumFieldDecorator(appiumDriver), this);
  }

  @AndroidFindBy(id = "com.mycompany:id/searchKeyword")
  public WebElement searchCase;
  
}

JDK: Open JDK 13

Appium Java Client : 7.2.0 - Debug View of 'searchCase' element after page factory init

result = {AndroidElement$$EnhancerByCGLIB$$b598166c@3735} "Located by By.chained({By.id: com.mycompany:id/searchKeyword})"
 CGLIB$BOUND = true
 CGLIB$CALLBACK_0 = {ElementInterceptor@3786} 
  locator = {AppiumElementLocator@3794} "Located by By.chained({By.id: com.mycompany:id/searchKeyword})"
   shouldCache = false
   by = {ContentMappedBy@3797} "By.chained({By.id: com.mycompany:id/searchKeyword})"
    map = {HashMap@3802}  size = 2
     {ContentType@3803} "NATIVE_MOBILE_SPECIFIC" -> {ByChained@3809} "By.chained({By.id: com.mycompany:id/searchKeyword})"
     {ContentType@3810} "HTML_OR_DEFAULT" -> {ByIdOrName@3811} "by id or name "searchCase""
    currentContent = {ContentType@3803} "NATIVE_MOBILE_SPECIFIC"
     name = "NATIVE_MOBILE_SPECIFIC"
     ordinal = 1

Appium Java Client: 7.3.0 - Debug View of 'searchCase' element after page factory init

result = {AndroidElement$$EnhancerByCGLIB$$b598166c@3703} "Located by By.id: searchCase"
 CGLIB$BOUND = true
 CGLIB$CALLBACK_0 = {ElementInterceptor@3755} 
  locator = {AppiumElementLocator@3763} "Located by By.id: searchCase"
   shouldCache = false
   by = {ContentMappedBy@3766} "By.id: searchCase"
    map = {HashMap@3771}  size = 2
     {ContentType@3778} "HTML_OR_DEFAULT" -> {ByIdOrName@3779} "by id or name "searchCase""
     {ContentType@3772} "NATIVE_MOBILE_SPECIFIC" -> {By$ById@3780} "By.id: searchCase"
    currentContent = {ContentType@3772} "NATIVE_MOBILE_SPECIFIC"
     name = "NATIVE_MOBILE_SPECIFIC"
     ordinal = 1

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 supplied HomeScreen reproduction using Appium Java Client 7.3.0, then compare PageFactory.initElements and AppiumFieldDecorator behavior with 7.2.0. The fix is complete when @AndroidFindBy resolves the native Android resource-id locator instead of falling back to the field name.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.