uiautomation iOS uilabel value
Asked Answered
C

2

3

I am trying to get the value from a UILabel by doing a target.logElementTree() but I am unable to see the value that the Label is actually set with.

It only shows the string that we set based on the accessibilityLabel

self.settlementDate.isAccessibilityElement = YES;
self.settlementDate.accessibilityLabel = @"DetailViewInCode_SettlementDate";

And in the target.logElementTree() this is the value that I see i the log of Instruments-Automation

UIAStaticText: name:DetailViewInCode_SettlementDate value:DetailViewInCode_SettlementDate rect:{{260, 345}, {304, 21}}    

UIALogger.logMessage("Target static:"+target.frontMostApp().mainWindow().staticTexts()["Activity_DetailedView_SettlementDate"].value());

And I can see the screenshot when I click on that entry
enter image description here

iOS 5.1 Simulator

Chloral answered 24/4, 2012 at 14:58 Comment(0)
L
3

It seems that the value is set by default with the value of accessibilityLabel property. Try to set the accessibilityValue property in the code in the same manner you set the accessibilityLabel property.

self.settlementDate.accessibilityValue = <ActualVale>;
Lalittah answered 10/7, 2012 at 10:55 Comment(1)
This is a really great piece of information. Setting both the accessibilityValue and accessibilityIdentifier of a UILabel provides a solution for something many people seem to look for but give up on: A way to easily get the value of a UILabel in a UIAutomation script, the way one would expect it to work: var foo = window.staticTexts()["myAccessibilityID"].value();Latarsha
S
-1

The value is shown in the log. The value of that label is DetailViewInCode_SettlementDate. The fact that the value and the name are identical might have been confusing you. This is not something uncommon.

Selima answered 15/5, 2012 at 14:10 Comment(1)
Try using the .label() attribute.Selima

© 2022 - 2024 — McMap. All rights reserved.