【问题标题】:Why is it the button in my view cant be seen by UIAutomation?为什么 UIAutomation 看不到我视图中的按钮?
【发布时间】:2011-01-13 07:15:18
【问题描述】:

我可以看到视图,但无法看到/点击其中的按钮。该按钮的可访问性标签为 UIA_loginview_loginbutton 并启用了可访问性。为什么它没有显示在 logElementTree() 上?

var target = UIATarget.localTarget();
var application = target.frontMostApp();
var window = application.mainWindow(); 
var view = window.elements().firstWithName("UIA_loginview_view"); 


UIATarget.localTarget().logElementTree();
UIATarget.localTarget().frontMostApp().logElementTree();


if(view == null || view.toString() == "[object UIAElementNil]") 
{
UIALogger.logFail("View not found - "+view.toString());
} 
else
{
    UIALogger.logPass("View found - "+view.toString());
    UIALogger.logMessage("View Elements length - "+view.buttons().length);
    view.buttons()["UIA_loginview_loginbutton"].tap();
}

日志元素树://显示我的视图,但不显示其中的按钮

4) UIAElement [name:UIA_loginview_view value:(null) NSRect: {{0, 20}, {320, 460}}]

【问题讨论】:

  • 能否请您使用编辑窗口顶部的 { } 格式化您的代码 - 这很有帮助!

标签: iphone ios ios-ui-automation


【解决方案1】:

确保按钮的可访问性属性不会被其容器视图隐藏。只有那些应该由用户访问的元素才应该被标记为这样。如果您在 Interface Builder 中设置启用“可访问性”的容器视图,则 UIAutomation 将看不到层次结构中的所有子元素。

这有帮助吗?

【讨论】:

  • 谢谢,我一直忘记这个!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-01
  • 2012-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多