Unable to get UIAutomation iOS UILabel value

instruments, ios, ios-ui-automation, ui-automation, xcode

Solution

I think you encountered a UIAutomation bug that exists since forever.

Easiest way to get around this bug is to set the accessibilityValue to your text in code.

Something like this.

NSString *valueString = [NSString stringWithFormat:@"%d", value];
self.label.text = valueString;
self.label.accessibilityValue = valueString;

Helps those people that use Voice Over too ;-)

Problem

I am trying to get the value `"HELLO"` of the `UILabel` shown in the iPad simulator. I have enabled accessibility and have set the label as `"Label Access"`. But when I call `target.logElementTree()`, both the name and value are set to `"LabelAccess"` and as far as the apple docs say, the value field should contain the string that is set (in this case `"Hello"`). Does anybody know a fix for this? PS: I am using the latest iOS SDK and Xcode. Apple Stack Exchange

Original source