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

i_raqz
  • 2,919
  • 10
  • 51
  • 87

2 Answers2

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>;
Sh_Andrew
  • 352
  • 2
  • 6
  • 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(); – Bill Agee Jul 30 '12 at 06:18
-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.