- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个具有以下结构的 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/
我有一个具有以下结构的 View : GrandView -Parent View1 -Parent View2 --Child View1 --Child View2 subview 几乎占据了 P
我正在尝试在循环中使用 isVisible() 来为我的 iOS UIAutomation 创建一个 waitForElement 类型的函数。当我尝试使用以下代码时,在弹出新屏幕时等待元素时失败。该
我注意到一段时间前编写的 UIAutomation 脚本中有一些奇怪的行为,但我已经有一段时间没有运行了。我的断言失败了;在进行一些挖掘之后,我发现在迭代 UIAElement 的 .elements
我在一些地方看到过这个 UIAElement 类,但我找不到太多关于它的文档。 这是由 Interface Builder 生成的吗?例如,如果我将一个 UIWebView 拖到 Interface
我是一名优秀的程序员,十分优秀!