我正在尝试实现一个 UIAutomation 脚本,如下所示:
var target = UIATarget.localTarget();
var window = target.frontMostApp().mainWindow();
var collectionView = window.collectionViews()[0];
collectionView.cells()[0].tap();
当我运行脚本时,我在日志中得到以下信息:
target.frontMostApp().mainWindow().collectionViews()[0].cells()[0].tap()
target.frontMostApp().mainWindow().collectionViews()[0].cells()[0].scrollToVisible()
Script threw an uncaught javascript error: t...cells()[0] could not be tapped
如果我在任何其他单元格上调用它,它会起作用,但由于某种原因第一个不起作用。有人遇到过这个问题吗?
最佳答案
我也遇到过这种情况。如果您使用 Instruments-> Automation 来录制新脚本,您会看到它通常执行 .tapWithOptions({tapOffset:{x:0.15, y:0.35}})
,而不是对象 .tap()
.
我不确定您的显示结构是什么,但我正在测试的应用程序在 Collection View 的单元格中有 Collection View 。虽然 target.frontMostApp().mainWindow().collectionViews()[0].cells()[0].collectionViews()[0].cells()[0]
工作 target .frontMostApp().mainWindow().collectionViews()[0].cells()[1].collectionViews()[0].cells()[0]
没有,target.frontMostApp( ).mainWindow().collectionViews()[0].cells()[1].collectionViews()[0].tapWithOptions({tapOffset:{x:0.17, y:0.42}})
有效,但是我宁愿 .cells()[0]
工作。
关于javascript - 无法点击 UIAutomation UICollectionView 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22861697/