gpt4 book ai didi

ios - UIAutomation 如何确定一个 UIAElement.isVisible()

转载 作者:可可西里 更新时间:2023-11-01 05:00:19 26 4
gpt4 key购买 nike

我有一个具有以下结构的 View :

GrandView
-Parent View1
-Parent View2
--Child View1
--Child View2

subview 几乎占据了 Parent View2 的所有边界,但边缘周围仍有一些空间。如果我点击边缘,我可以使用辅助功能检查器在模拟器中选择 Parent View2。如果我使用,我还可以在 UIAutomation 中点击 Parent View2:

tapWithOptions({tapOffset:{x:0.15, y:0.95}});

但是,我对 isVisible() 的调用总是返回 0。我希望如果我可以点击该元素,或者使用辅助功能检查器选择它,它应该返回 1

UIAutomation 如何确定 UIAElement 是否可见?

最佳答案

您对元素执行的每个操作都有超时。这在 Apple 文档中并不明显,但如果您查看:setTimeout ,它告诉我们:

The timeout value establishes a grace period for object resolution. If an object representing a UI element becomes available within the grace period, an attempt is made to instantiate that object from information retained by the instrument.

setTimeout 本身只是更改默认值(推送和弹出也是如此)。您真正想做的是对您的 View 执行操作,如果它永远不可用(默认超时为 5 秒),则在超时时失败。
WWDC 2010 session “使用仪器自动化用户界面测试”确实深入了解一下,它在 ADC 上可用 WWDC 2010页面,包含视频和幻灯片。在您的情况下,您希望在 View 上执行 tap() 。如果出于某种原因,该 View 在 5 秒内对 UIAutomation 不可用,您应该会看到一个异常。
尝试通过以下方式更改超时:

var oldTimeout = target.timeout();target.pushTimeout(10);

在你的代码之前,和

target.popTimeout(oldTimeout);

之后。

关于ios - UIAutomation 如何确定一个 UIAElement.isVisible(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8852977/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com