我试图在我的iOS应用程序中做一个简单的UI测试。我想用一些文本填充textfield,但是总是会出现错误。
第一次尝试:
let searchField = app.textFields.elementBoundByIndex(0);
searchField.tap()
searchField.typeText("Holy Grail")该字段被高亮显示,键盘出现,几秒钟后,随机出现其中之一:
- Timed out waiting for IDE barrier message to complete
- failed to get attributes within 15.0s ui test
- failed to get snaphots within 15.0s ui test第二次尝试:
func setText(text: String, application: XCUIApplication) {
//Instead of typing the text, it pastes the given text.
UIPasteboard.generalPasteboard().string = text
doubleTap()
application.menuItems["Paste"].tap()
}
...
let searchField = app.textFields.elementBoundByIndex(0);
searchField.tap()
searchField.setText("Holy Grail")同样的结果。尝试与Connect Hardware Keyboard断断续续。用iPhone 6s模拟器、iPad Retina仿真器、iPad 2模拟器试过。只尝试使用Xcode 7 (8将破坏项目)
想法?提前感谢!
发布于 2020-05-20 09:12:59
首先,尝试禁用I/O ->硬件键盘,看看会发生什么。如果仍然不起作用
而不是
searchField.tap()
searchField.typeText("Holy Grail")尝尝这个
app.keys["H"].tap()
app.keys["o"].tap()
app.keys["l"].tap()
app.keys["y"].tap()https://stackoverflow.com/questions/40332258
复制相似问题