开发者

iOS/UIAutomation: How can i use isVisible() for the buttons in the second unlabeled toolbar?

I am trying to use UIAutomation in Instruments with the iPhone Simulator and the latest iOS SDK 4.2. in my app that has 2 unlabeled toolbar, i have just only access to the head-toolbar like :

var window = UIATarget.localTarget().frontMostApp().mainWindow();

window.toolbar().buttons()["upload"].isVisible();

and can not use isVisible() for the buttons (cancel,ok,forward) in the remain unlabeled toolbar (enclosed my logs below)

4) UIAToolbar [name:(null) value:(null) NSRect: {{0, 20}, {320, 44}}] 5) UIAButton [name:angle_bracket_left_i value:(null) NSRect: {{-3, 16}, {50, 51}}] 5) UIAButton [name:angle_bracket_right_ value:(null) NSRect: {{27, 16}, {50, 51}}] 5) UIATextField [name:(null) value开发者_StackOverflow:http://www.google.com.vn/ NSRect: {{72, 29}, {164, 26}}] 5) UIAButton [name:upload value:(null) NSRect: {{246, 29}, {34, 27}}] 5) UIAButton [name:Refresh value:(null) NSRect: {{285, 24}, {28, 33}}] 4) UIAToolbar [name:(null) value:(null) NSRect: {{0, 436}, {320, 44}}] 5) UIAButton [name:cancel value:(null) NSRect: {{1, 439}, {50, 40}}] 5) UIAButton [name:ok value:(null) NSRect: {{132, 430}, {50, 51}}] 5) UIAButton [name:forward value:(null) NSRect: {{263, 430}, {50, 51}}]


There are several ways to access buttons on your second toolbar.

1) use window.toolbars()[1].buttons() to get array of buttons for your second toolbar

2) address buttons directly by using window.buttons()[button_name].isVisible()

Most appropriate in my mind would be to set accessibility label for your second toolbar in Xcode and then address it in UI javascript by name. It is also better because your second toolbar name will be accessible for disabled people using VoiceOver.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜