为什么 UIAutomation 看不到我视图中的按钮?
我可以看到视图,但无法看到/点击其中的按钮。该按钮具有 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}}]
i am able to see the view but im unable to see/tap the button inside it. The button has a accessibility label of UIA_loginview_loginbutton with accesibility enabled. why is it not showing on 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();
}
Log Element Tree: //Shows my view but not the button inside it
4) UIAElement [name:UIA_loginview_view value:(null) NSRect: {{0, 20}, {320, 460}}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保按钮的可访问性属性不会被其容器视图隐藏。只有那些用户应该可以访问的元素才应该被标记为这样。如果您在 Interface Builder 中设置启用“可访问性”的容器视图,则 UIAutomation 将看不到层次结构中的所有子元素。
有帮助吗?
Ensure that the accessability property of the button is not hidden by its container views. Only those elements, which should be accessable by the user should be marked as such. If you set a container view enabled "Accessability" in Interface Builder all subelements in the hierarchie will not be visible by UIAutomation.
Did that help?