我有这个应用程序,我正在使用Apple提供的UIAutomation框架编写自动化测试脚本。在我的应用中,我想点按一个按钮,该按钮是UIATableCell()
的孩子,而该按钮又是我应用的mainWindow()
的孩子。当我运行命令logElementTree()
时,显示以下内容:
我尝试不能访问此按钮。有谁可以帮我如何访问这个按钮?
答案 0 :(得分:0)
试试这个:
var buttonToTap = mainWindow().cells()[0].buttons()[0].tap();
if ( buttonToTap.checkIsValid() )
buttonToTap.tap();
如果您尝试点击的单元格中的文本在应用程序运行期间不会更改,您可以尝试使用对象名称而不是索引:
var textInCell = "You have not talked to anyone named 'Bugles'";
var buttonToTap = mainWindow().cells()[textInCell].buttons()[textInCell].tap();
if ( buttonToTap.checkIsValid() )
buttonToTap.tap();