Ann
Ann

Reputation: 485

Accessibility label in UIAutomation

Is it possible to avoid accessibility labels when using UIAutomation?

Upvotes: 1

Views: 743

Answers (3)

Yoi-Nami-Ra
Yoi-Nami-Ra

Reputation: 126

If you want it to be seen by UIAutomation but not by applications like VoiceOver, you should use accessibilityIdentifier property of UIAccessibilityIdentification Protocol.
It allows you to set the value later seen trough UIAElement.name

Normally when not set, name is copied from the label.
But when the second is seen by VoiceOver the first one is not.

This is available in iOS 5.0 and later.

You can as well look at the UIAccessibility Protocol it has some more nice tricks.

Upvotes: 3

CedricSoubrie
CedricSoubrie

Reputation: 6697

In general, you have two ways to access an element : by its label or by its rank. Example :

target.frontMostApp().mainWindow().tableViews()[0]

or target.frontMostApp().mainWindow().tableViews()["Contents"]

You can choose which one you want to use in UIAutomation by clicking on the element in the script editor.

Upvotes: 1

Rog
Rog

Reputation: 17170

Unless your app is very simple*, it is not. UIAutomation relies on accessibility labels.

Even if you could do this, you would not save any effort, you would still need to provide some way for UIAutomation to identify your UI elements.

* the simple case would be where there is only one distinct UIView subclass on screen at once. In this case, UIAutomation will generate anonymous references to the unanamed element which allow your scripts to hobble along. It is very brittle though.

Upvotes: 1

Related Questions