Accessibility Identifier not visible in Accessibility Inspector with iOS Simulator

前端 未结 5 1501
后悔当初
后悔当初 2021-02-15 13:00

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

相关标签:
5条回答
  • 2021-02-15 13:37

    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!

    0 讨论(0)
  • 2021-02-15 13:37

    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.

    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.

    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.

    voila!

    0 讨论(0)
  • 2021-02-15 13:39

    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 讨论(0)
  • 2021-02-15 13:50

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

    0 讨论(0)
  • 2021-02-15 13:51

    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:

    0 讨论(0)
提交回复
热议问题