使用仪器自动化ui测试从表视图中删除项目

时间:2013-09-06 09:59:58

标签: ios testing tableview

我正在尝试使用仪器自动化UI测试从食谱应用程序中的列表中删除项目。我记录了一个项目的删除,我改变了相同的其他名称,但它不起作用请帮助我。

这是我的代码

var target = UIATarget.localTarget();

target.frontMostApp().navigationBar().leftButton().tap();

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[" "].switches()["Delete MAggi "].setValue(<value>);

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[" "].buttons()["Confirm Deletion for MAggi "].tap();

target.frontMostApp().navigationBar().leftButton().tap();

1 个答案:

答案 0 :(得分:1)

好吧,假设您在表格视图中有一个名为&#34; MAggi&#34;的食谱,​​以下内容应该有效:

var target = UIATarget.localTarget();

target.frontMostApp().navigationBar().leftButton().tap();

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["MAggi"].switches()["Delete MAggi"].tap();

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["MAggi"].buttons()["Delete"].tap();

target.frontMostApp().navigationBar().leftButton().tap();

而不是尝试setValuetap()&#34;删除MAggi&#34;按钮。此外,您需要确保在.tableViews()

之后的方括号中指定正确的表名