我想在iOS應用程序中進行簡單的UI測試。我想用一些文字填寫textfield
,但總會出現錯誤。在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將打破該項目)
想法?提前致謝!