如何使用 UITest 和 Swift 3 单击编辑菜单
How do I click on an edit menu using UITest and Swift 3
在我的 UITest 中,我可以在文本视图中长按,弹出一个编辑菜单,其中包含两个选项 Select 和 Select 全部。我如何选择其中之一?这是我的代码,它在第三行失败了。
app.textViews["noteText"].tap()
app.textViews["noteText"].press(forDuration: 2)
app.staticTexts["Select All"].tap()
Swift 2.3 答案:app.descendantsMatchingType(.Any).elementMatchingType(.Any, identifier: "Select All")
Swift 3 个回答:app.descendants(matching: .any).element(matching: .any, identifier: "Select All").tap()
不清楚为什么不同的查询 return 不同的结果,但这个查询始终 return 是我经验中所有查询的最大超集,只要标识符在整个查看层次结构。
在我的 UITest 中,我可以在文本视图中长按,弹出一个编辑菜单,其中包含两个选项 Select 和 Select 全部。我如何选择其中之一?这是我的代码,它在第三行失败了。
app.textViews["noteText"].tap()
app.textViews["noteText"].press(forDuration: 2)
app.staticTexts["Select All"].tap()
Swift 2.3 答案:app.descendantsMatchingType(.Any).elementMatchingType(.Any, identifier: "Select All")
Swift 3 个回答:app.descendants(matching: .any).element(matching: .any, identifier: "Select All").tap()
不清楚为什么不同的查询 return 不同的结果,但这个查询始终 return 是我经验中所有查询的最大超集,只要标识符在整个查看层次结构。