java-client icon indicating copy to clipboard operation
java-client copied to clipboard

@iOSXCUITFindBy element lookup uses 'id' instead of 'accessibility id' for Page Factory annotations on an IOSElement and fails to find it (native app)

Open squeemish opened this issue 8 years ago • 14 comments

Description

The variable name assigned to an IOSElement in Page Factory annotation is used to lookup the element instead of the actual annotation locator provided.

Logs show [HTTP] --> POST /wd/hub/session/3ade3d73-6606-484d-a752-6decdab285d3/element {"using":"id","value":"subtitle"} as opposed to [HTTP] --> POST /wd/hub/session/3ade3d73-6606-484d-a752-6decdab285d3/element {"using":"accessibility id","value":"activationLink"} when @iOSFindBy is used

Environment

  • java client build version or git revision if you use some shapshot: 5.0.0 BETA9
  • Appium server version or git revision if you use some shapshot: 1.6.5/Latest Desktop
  • Desktop OS/version used to run Appium if necessary: macOS10.12.6
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: Appium.app 1.1.1
  • Mobile platform/version under test: iOS 10.3
  • Real device or emulator/simulator: real device

Details

ActivationLinkPage: https://gist.github.com/squeemish/251504367c13caa16ef04336c75cfb4c Driver/Appium creation: https://gist.github.com/squeemish/7c77faaa839b5d7ffcb82f9d1515d05b POM with system properties: https://gist.github.com/squeemish/fd8f80dfd1e5730d471f9179a4183cf0

Ecxeption stacktraces

https://gist.github.com/squeemish/c6d64fa082f5d3c1a7775bae2303d030

Link to Appium logs

https://gist.github.com/squeemish/eac632e9b22836a436f500c460306914

squeemish avatar Aug 01 '17 11:08 squeemish

Hi,

I am also facing the same problem. I am on Appium: 1.7.0. Please help

Thanks Guru

guruprasadsr avatar Oct 29 '17 07:10 guruprasadsr

For me the log shows "id", however, it treats the value as "accessibility id", so it still finds the right element.

dianhua1560 avatar Mar 23 '18 20:03 dianhua1560

Any updates on this issue?

akash1205 avatar Apr 25 '18 14:04 akash1205

I have the same bug as well. I had to modify my MobileElements to be the same as accessibility id in IOS app =)

@AndroidFindBy(id = "com.ghm.free2move.wdc.integration:id/burgerIcon") @iOSXCUITFindBy(id = "icMenu") public MobileElement icMenu; public MobileElement getMainMenuItem() { return icMenu; }

or in another case it will not work. My Appium java-client version is:

             <groupId>io.appium</groupId>
             <artifactId>java-client</artifactId>
             <version>7.0.0</version>

Please look into that as seems we are blocked in case if there is no ID for element (xpath only for example).

viktorgogulenko avatar Jan 08 '19 11:01 viktorgogulenko

Same issue, the variable name is used instead of the annotation parameter, using java-client 7.0.0.

cosminstirbu avatar Feb 02 '19 14:02 cosminstirbu

I had the same issue and found the solution: add the following capability to your driver initialization: capabilities.setCapability("automationName", "XCUITest")

Explanation here: http://appium.io/docs/en/drivers/ios-xcuitest/index.html

tobizwetz avatar Feb 28 '19 14:02 tobizwetz

@tobizwetz even capabilities.setCapability("automationName", "XCUITest") is not working.. any other work arounds>

ghost avatar Aug 30 '19 13:08 ghost

I had this problem to, but only on appium java client version 7.3.0. On 7.2.0 it's work fine. I suspect it is a bug in new version.

czandler22 avatar Jan 17 '20 13:01 czandler22

I can confirm the same for @AndroidFindBy too.

7.2.0:

  • @AndroidFindBy(accessibility = "email") do the same as driver.findElement(MobileBy.AccessibilityId("email"))

7.3.0:

  • @AndroidFindBy(accessibility = "email") do the same as driver.findElement(By.id("email"))

dtopuzov avatar Mar 13 '20 18:03 dtopuzov

Updates:

When use

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, org.openqa.selenium.Platform.ANDROID);

I hit the issue/

When use

capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, org.openqa.selenium.Platform.ANDROID.toString());

It works properly even with 7.3.0

May is happens because this check looks for String.class: https://github.com/appium/java-client/blob/6cd31e2b2eb979bea389918ac42f5b7ed6c40b60/src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java#L91

dtopuzov avatar Mar 14 '20 12:03 dtopuzov

platformName must be a string according to the standard: https://w3c.github.io/webdriver/#capabilities

mykola-mokhnach avatar Mar 14 '20 12:03 mykola-mokhnach

Having the same issue with "iOSXCUITFindBy" when the platformName = "tvOS". Still going through/trying to understand the code but looks like TVOS was not handle in "buildMobileNativeBy" method of https://github.com/appium/java-client/blob/v7.1.0/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java

if (isIOSXcuit() || isIOS()) { ////Should we have istvOS() return buildMobileBy(howToUseLocatorsOptional.map(HowToUseLocators::iOSXCUITAutomation).orElse(null), getBys(iOSXCUITFindBy.class, iOSXCUITFindBys.class, iOSXCUITFindAll.class)); }

Appium 1.17.1 Java Client 7.3.0 macOS Catlina Apple TV Real device Java 8 or 11 or 12

pavanredt avatar Jun 30 '20 05:06 pavanredt

@iOSXCUITFindBy is working fine when the platformName = "tvOS" once i make following changes. It would be of great help if any of the contributors can review and implement the same.

  1. Add the following in https://github.com/appium/java-client/blob/v7.1.0/src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java

    protected boolean isTVOS() { return TVOS.equalsIgnoreCase(platform); }

  2. update line 173 in https://github.com/appium/java-client/blob/v7.1.0/src/main/java/io/appium/java_client/pagefactory/DefaultElementByBuilder.java to

if (isIOSXcuit() || isIOS() || isTVOS()) {

Thanks

pavanredt avatar Jul 02 '20 03:07 pavanredt

Anyone can please help me how to use xpath with @iOSXCUITFindBy Example: @iOSXCUITFindBy(xpath = "//XCUIElementTypeButton[@name='Next']") This is returning error.

Anyone can please help me in this?

STC-FaizanMamji avatar Dec 02 '21 15:12 STC-FaizanMamji