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

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

Open
squeemish opened this issue Aug 1, 2017 · 14 comments
Assignees

Comments

@squeemish
Copy link

squeemish commented Aug 1, 2017

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 squeemish changed the title variable name used for element lookup instead of Page Factory annotation for IOSElement (native app) @iOSXCUITFindBy element lookup uses 'id' instead of 'accessibility id' for Page Factory annotations on an IOSElement (native app) Aug 1, 2017
@squeemish squeemish changed the title @iOSXCUITFindBy element lookup uses 'id' instead of 'accessibility id' for Page Factory annotations on an IOSElement (native app) @iOSXCUITFindBy element lookup uses 'id' instead of 'accessibility id' for Page Factory annotations on an IOSElement and fails to find it (native app) Aug 1, 2017
@TikhomirovSergey TikhomirovSergey self-assigned this Aug 5, 2017
@guruprasadsr
Copy link

Hi,

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

Thanks
Guru

@dianhua1560
Copy link

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

@akash1205
Copy link

Any updates on this issue?

@viktorgogulenko
Copy link

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

@cosminstirbu
Copy link

cosminstirbu commented Feb 2, 2019

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

@tobizwetz
Copy link

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

@ghost
Copy link

ghost commented Aug 30, 2019

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

@czandler22
Copy link

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.

@dtopuzov
Copy link

dtopuzov commented Mar 13, 2020

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

dtopuzov commented Mar 14, 2020

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:

this.platform = CapabilityHelpers.getCapability(caps, "platformName", String.class);

@mykola-mokhnach
Copy link
Contributor

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

@pavanredt
Copy link

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

@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

@STC-FaizanMamji
Copy link

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?

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

No branches or pull requests