Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagefactory AndroidFindBy not taking effect on appium java 7.3.0 #1275

Open
rapidroamer opened this issue Dec 1, 2019 · 8 comments
Open

Comments

@rapidroamer
Copy link

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
@ervuks
Copy link

ervuks commented Jan 15, 2020

Just run into the same issue. Made rollback to 7.2.0
Instead of taking elements provided ID, it takes name of MobileElement object as ID.

@miguelsuddya
Copy link

@mykola-mokhnach Any comments on this issue?
I have exactly the same problem.

@mehedihasan619
Copy link

I am also facing the issue of Appium java client 7.3.0.

@dtopuzov
Copy link

dtopuzov commented Jun 16, 2020

@mehedihasan619 @miguelsuddya @ervuks @rapidroamer
Please see last comments in this issue: #683

It looks similar.

@mehedihasan619
Copy link

mehedihasan619 commented Jun 22, 2020

@dtopuzov Thanks.
I was able to make it work with @AndroidFindBy. Previously I was using @AndroidBy
I also used AndroidDriver instead of AppiumDriver.

@hwulfmeyer
Copy link

hwulfmeyer commented Jul 8, 2020

Ran into the same issue.

I have a relatively simple testcase.
https://gist.github.com/wulfihm/a1419441ee800a0cb16049b876737c44

It looks for the variable name as the id.

[debug] [WD Proxy] Matched '/element' to command name 'findElement'
[debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:39744/wd/hub/session/9c050cac-4365-417b-b21e-b35833d77851/element] with body: {"strategy":"id","selector":"loginField","context":"","multiple":false}
[WD Proxy] Got response with status 404:

MyAndroidDriver is an extensions of AndroidDriver<AndroidElement>.

Version 7.3.0

Using
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, org.openqa.selenium.Platform.ANDROID.toString());
resolved my issue.

Thanks to: #683 (comment)

Using Platform.ANDROID.name() is probably even better because toString() is something that is evaluated automatically.

@mehedihasan619
Copy link

mehedihasan619 commented Jul 9, 2020

@saravanan060694
Copy link

In my case not able to initialize the @androidFindBy, could someone help me on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants