Strong password autofill appears in iOS simulator

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:

  • Tap in the first create password field
  • Enter a password
  • Tap in the confirm password field
  • Enter the same password

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?

小智 18

有同样的问题。对我有用的是模拟器的设置 -> 密码 -> 打开然后关闭自动填充密码。


小智 15

进入模拟器的设置 -> 密码 -> 打开然后关闭自动填充密码。

在此处输入图片说明

输入任何密码

在此处输入图片说明

在此处输入图片说明


Luk*_*asz 5

不确定从一开始是否就是这样,但设置也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)