【问题标题】:iOS/UIAutomation: How can i use isVisible() for the buttons in the second unlabeled toolbar?iOS/UIAutomation:如何将 isVisible() 用于第二个未标记工具栏中的按钮?
【发布时间】:2011-03-28 07:52:27
【问题描述】:

我正在尝试通过 iPhone 模拟器和最新的 iOS SDK 4.2 在 Instruments 中使用 UIAutomation。在我有 2 个未标记工具栏的应用中,我只能访问 head-toolbar,例如:

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

window.toolbar().buttons()["上传"].isVisible();

并且不能对未标记工具栏中的按钮(取消、确定、前进)使用 isVisible()(在下面附上我的日志)

4) UIAToolbar [名称:(null) 值:(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:http://www.google.com.vn/ NSRect: {{72, 29}, {164, 26}}] 5) UIAButton [名称:上传值:(null) NSRect: {{246, 29}, {34, 27}}] 5) UIAButton [名称:刷新值:(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}}]

【问题讨论】:

    标签: iphone ios-4.2 ios-ui-automation


    【解决方案1】:

    有几种方法可以访问第二个工具栏上的按钮。

    1) 使用 window.toolbars()[1].buttons() 获取第二个工具栏的按钮数组

    2) 使用 window.buttons()[button_name].isVisible() 直接寻址按钮

    在我看来,最合适的方法是在 Xcode 中为您的第二个工具栏设置可访问性标签,然后在 UI javascript 中按名称对其进行寻址。这也更好,因为使用 VoiceOver 的残疾人可以访问您的第二个工具栏名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 2011-04-20
      • 1970-01-01
      相关资源
      最近更新 更多