Appium Unable to Find/Locate iOS Accessibility Identifiers or Accessibility Label on UIAButton Elements

Hello Appium Gurus,

I’ve been working on trying to get some iOS accessibility properties set programmatically so that while using Appium, I can access these elements for automated testing.

Over the past few days, I’ve been unable to get Appium to recognize that these properties have been set and am having trouble determining if Appium even gets these values from the iOS code.

I’ve been working with the developer to make sure that these properties are being set via Code. We’ve added anything relevant by the accessibility properties which might help make the elements identifiable within Appium like below:

profile.tabBarItem.accessibilityIdentifier = @"profile";
profile.tabBarItem.accessibilityLabel = @"profile";
profile.tabBarItem.accessibilityHint = @"profile";
profile.tabBarItem.accessibilityValue = @"profile";

However, Once the app is built and run within Appium these Values never show up or Appium fails to recognize these properties were set. Once in the inspector, I’ve attempted to find these values by selecting “Locator”, Chosing Strategy “accessibility id” and entering value of “profile”. I have also tried just “id”. The appium tool/inspector returns that no elements were found.

The Parent Element to Tab Bar Hierarchy is as follows with a Tab Bar that contains 5 Buttons.

[UIAApplication]->[UIAWindow] → [UIATabBar] ->[UIAButton]

Upon Selecting these through the Inspector the only information that comes up about said button is:

type: UIAButton
enabled: true
visible: false
valid: true
location: {302, 619}
size: {71, 48}
xpath: //UIAApplication[1]/UIAWindow[1]/UIATabBar[1]/UIAButton[5]

So, my questions are as follows:

  1. Are the properties being set correctly programmatically?
  2. Can UIAButtons that live under a UIATabBar have these properties set?
  3. Am attempting to Locate them correctly using the ‘locator’ and ‘value’ properly?
  4. If this doesn’t show via the Appium inspector, can they still be accessed via scripts running tests even though Appium cannot find these properties?
  5. Is this a Bug/Issue instead?

Please let me know if i’m missing something. Thanks!

I recommend testing with the Apple Accessibility Inspector

Another idea, you might need to set it as an accessibility element

Hi, thanks for the reply. I have tested this with the simulator’s Apple accessibility inspector, and it fails to recognize the id as well. The only information i get out of it is as follows when I select the button with the inspector:

Traits: Button
Frame: {302,619}, {71,48}

I will look into seeing if the element it self needs to be set as isAccessibilityElement = YES;

Thank you for providing the article. I will post back with my findings.

I’m also having the same issue. Appium is unable to identity values for few elements on real device.
I have to use xpath. Please let me know if we can identify values for other properties so I can use name instead of xpath.

type: UIANavigationBar
enabled: true
visible: false
valid: true
location: {0, 0}
size: {320, 68}
xpath: //UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]

@DanSmithSC did it work for you?

There are also 2 really great program options out there to assist in determining your app’s current accessibility settings

  1. Spark:
  2. Reveal: reveal

I’ve used reveal quite a bit and liked it. My friend uses spark and likes it

Additionally, you may want to use the appium ruby console (arc) in addition to the appium inspector. Many times I find additional elements in arc that were not in the inspector. There’s plenty of documentation on arc if you if you search for it.

Good luck!

I think you’re missing:

profile.tabBarItem.isAccessibilityElement = YES;

As I understand it, Appium drives the user interface via UI Automation. Consequently, it can only drive user interface elements that are ‘Accessible’. In particular, each UIView must have isAccessibilityElement == YES. There are additional requirements for custom views.

When working with standard UIKit views, I’ve had good results with code like:

view.isAccessibilityElement = YES; // makes an Appium element available
view.accessibilityIdentifier = @"aName"; // makes the Appium element name="aName"
view.accessibilityValue = @"aValue"; // makes the Appium element value="aValue"

I don’t use accessibilityLabel and accessibilityHint for Appium. Instead, I use them to enable blind and low sight users to understand the app, as Apple advises.

@jkristian: After multiple attempts to set the property like you’ve shown, it still never worked. We attempted to do this many times prior to your response too and instead had to use an alternative solution.

Been a while, but we ended up going with a solution sort of like the one proposed here:

In the Code we went with this:

profile.tabBarItem.title = @"profile";
    [profile.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor clearColor]} forState:UIControlStateNormal];

We set the TitleText with"UIColor clearColor". We get access to the title for automation purposes, but we get the desired element with no visible text.

Alpesh, did you find solution for this…as it is difficult to work without Id or Name, because indexes gets changed frequently and hence xpath gets changed…thanks in advance for your help.

1 Like