[英]UIAutomation [UITextField resignFirstResponder]
How can I get the keyboard dismissed when using UI Automation tests? 使用UI自动化测试时如何解开键盘? I've been looking at UIAElement and UIATextField documentation but couldn't find something that suggests so.
我一直在查看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
}
Quite an old question but I had to deal with that right now. 相当老的问题,但我现在必须处理。 This command worked perfectly :
该命令完美运行:
target.frontMostApp().keyboard().typeString("\n");
From UIAutomation, you don't really have access to the internals to do things like resign first responder--UIAutomation is just like a regular user of your app. 在UIAutomation中,您实际上无权访问内部人员来执行诸如辞退第一响应者之类的操作-UIAutomation就像您应用程序的常规用户一样。 Could you do:
你能做:
app.keyboard().buttons()["return"].tap();
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.