14

I wanted to use the Accessibility Inspector to verify all the accessibility identifiers in my app running in the simulator (iOS 9.2).

Accessibility Inspector is able to return multiple accessibility fields but not the identifiers.

Any idea why and how I could see them ?

1
  • Make sure you read the (non checked) answers by Chris Prince (2017) and Saleh (2018), this can be done!
    – David H
    Commented Jun 28, 2019 at 14:38

6 Answers 6

19

There is actually a way, and Chris Prince missed out on explaining how to get to it. You start off by bringing up the inspector.

Showing the top bar

The bar above basically focuses the inspector to whatever process you need to inspect. In our case it should be simulator.
Edit: as pointed out by Dallas, you have to click on the left half revealing the possible targets. Click on the Simulator to have the Inspector target it.

Showing Simulator focus

Something to note that it seems that simulators have their own information to show. Focusing on the simulator will automatically add in the identifier and show the proper accessibility information.

Showing the identifier appearing

voila!

4
  • Fantastic! This is a huge help to me!
    – David H
    Commented Jun 28, 2019 at 14:39
  • 1
    This didn't help me at first but then I worked it out, make sure you select the option on the left of the drop-down and select "Simulator ...." Commented Oct 24, 2019 at 23:14
  • Oh I didn't think that was also not obvious, I'll add it up
    – Saleh
    Commented Oct 26, 2019 at 2:26
  • 1
    They added this property to Accessibility Inspector a while back. This should be the accepted answer now :)
    – MobA11y
    Commented Jan 30, 2020 at 15:43
8

I have only recently started using accessibility features, but at least as of Xcode9.1b2, accessibility identifiers are visible within the Accessibility Inspector. See for example:

enter image description here

5
  • What is the version of your Accessibility Inspector? Because mine is not showing the identifier. I am using Xcode9.1, accessibility inspector version 5.0
    – Hasaan Ali
    Commented Nov 29, 2017 at 8:11
  • Mine is showing Version 5.0 (70), but I'm away from this work with accessibility identifiers, so I'm not able to see if I can reproduce this with this version (water under the bridge, changes to Xcode, MacOS versions etc.). Commented Nov 29, 2017 at 20:03
  • I'm using 5.0 (71) and it's not showing identifiers for all elements - just for some of them. I.e. - i'm not able to see ids for textfields but it works for buttons and labels.
    – Kubba
    Commented Dec 6, 2017 at 12:47
  • 2
    Alhamdulillah (Praise be to Allah :) I figured it out. The Identifier is only shown if you are inspecting the app on THE SIMULATOR. Its NOT shown when inspecting on real device. That is why it was shown to you too @ChrisPrince
    – Hasaan Ali
    Commented Dec 8, 2017 at 16:00
  • 3
    Has anyone been able to see the accessibility ids for textfields? I'm using Version 5.0 (71.43) and still unable to.
    – Daniel Hsu
    Commented Apr 6, 2018 at 17:28
2

You will never be able to (without changes from Apple) see this property in Accessibility Inspector, because it isn't really used for accessibility. That it is associated with accessibility is a misnomer, related to accessibility API's generic value in identifying elements for automated testing using UI Automation, because accessibility information is available cross process. To get this info you could cast UI elements to UIAElements and access the name property, and pass this to NSLog.

EDIT: Yep, look at Saleh's answer. Apple added this at some point! Be wary about relying on this, Accessibility Inspector has been very buggy and unstable for me recently. But that answer would be the accepted answer if you're not answering this 3 years ago!

4
  • is this still true for the new accessibility inspector in xcode 8?
    – fabb
    Commented Jan 11, 2017 at 10:58
  • I don't see it in Accessibility Inspector 5.0, which comes with Xcode 8.2.1.
    – Uncommon
    Commented Mar 6, 2017 at 22:26
  • This is relevant: "Unlike the rest of the accessibility information in the Identity Inspector, the identifier is not part of the UIAccessibility protocol. It corresponds to the accessibilityIdentifier property of the UIAccessibilityIdentification protocol. This value is meant to be used to uniquely identify views in the context of UI tests" Source: revealapp.com/blog/exploring-accessibility.html scroll down to Identifier heading
    – Hasaan Ali
    Commented Dec 8, 2017 at 15:16
  • Nope, not true, the below answer is a better answer if you're in the 2020s :)
    – MobA11y
    Commented Jan 10, 2020 at 20:14
0

Xcode is so flaky, sometimes the Accessibility Label or Identifier will not show in the Accessibility Inspector. When this happens I just

  1. Set the Label and/or Identifier
  2. Edit the display text under the Attribute Inspector, the value right under the Text selector. After doing a build I will change the value back.
  3. Or add a IBOutlet then delete it.

If you change just the Label or Identifier Xcode does not detect it.

0

Make sure you have XCode opened in the background (even though you are using Accessibility Inspector standalone app)

0

It looks like in the current, as of this writing, version of Xcode (v15.0), the Identifier is visible in the "Advanced" group (below "Basic" and "Actions")

1
  • Apparently as of May 24th, the Advanced group was removed. This is silly. Commented May 24 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.