Est*_*tel 5 autofill ios uitest xcuitest
Our UI test suites are showing some unexpected behaviour where our Create Password screen intermittently auto-completes both the username and password - this results in the test being failed.
The process is something like:
This last step fails because the passwords in both fields have been auto-completed.
This happens for about one in every ten to twenty test executions.
Our understanding is that the password auto-fill should never be seen in any simulator, so it's very confusing to see this at all. Is there something that we can do to extra disable autofill, or otherwise prevent this from happening?
不确定从一开始是否就是这样,但设置也isSecureTextEntry = true足以触发该错误(至少在 Xcode 12.2 中)。
因此,对我有用的解决方法是:
let field = UITextField()
if #available(iOS 11.0, *) {
#if targetEnvironment(simulator)
// Do Not enable '.password' or '.newPassword' or 'isSecureTextEntry' text content type on simulator as it ends up with annoying behaviour:
// 'Strong Password' yellow glitch preventing from editing field.
print("Simulator! not setting password-like text content type")
#else
field.textContentType = .password
field.isSecureTextEntry = true
#endif
}
field.placeholder = "Password"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
540 次 |
| 最近记录: |