[英]UIAutomation [UITextField resignFirstResponder]
使用UI自動化測試時如何解開鍵盤? 我一直在查看UIAElement和UIATextField文檔,但找不到建議的內容。
var textField = toolbar.textFields()[0];
var textView = toolbar.textViews()[0];
function testFeature1() {
if (textField.hasKeyboardFocus() || textView.hasKeyboardFocus()) {
// Resign first responder .. How?
}
// Do my tests
}
相當老的問題,但我現在必須處理。 該命令完美運行:
target.frontMostApp().keyboard().typeString("\n");
在UIAutomation中,您實際上無權訪問內部人員來執行諸如辭退第一響應者之類的操作-UIAutomation就像您應用程序的常規用戶一樣。 你能做:
app.keyboard().buttons()["return"].tap();
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.