Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I set accessibility identifier in interface builder? Xcode4.2

I can only set Accessibility Label in interface builder, but in UI Automation,I need Accessibility Identifier to get the UI elements. any way to do this?

like image 915
CarmeloS Avatar asked Oct 26 '11 09:10

CarmeloS


2 Answers

The accessibilityIndentifier can be set in IB by using the Identity Inspector tab's 'User Defined Runtime Attributes':

Key Path: accessibilityIdentifier

Type: String

Value: Chosen accessibilityIdentifier text

E.g. setting a scroll view to have the accessibility ID 'ScrollView': Image from Xcode 8.3.2

Note: This can only be used on items that have the accessibilityIdentifier property meaning they inherit from UIView. Also, typos in 'Key Path' will probably cause an exception when the item is loaded, I don't believe a compile warning/error would be given.

like image 76
Joseph Avatar answered Sep 24 '22 04:09

Joseph


In Xcode 7.1 (ios 9.0) you could do it as simple as possible. Please find the image attached.

enter image description here

You could simply access it as view.accessibilityIdentifier

like image 43
Anees Avatar answered Sep 20 '22 04:09

Anees