如何消除“想要保存此密码以便在应用程序和网站上使用?” 在执行 UI 测试期间

chi*_*dro 10 passwords swift xcuitest

我目前正在使用

addUIInterruptionMonitor(withDescription: "System alerts") { alert in
      let notNowButton = alert.buttons["Not Now"]
      if notNowButton.exists {
         notNowButton.tap()
         return true
      }
      return false
 }
Run Code Online (Sandbox Code Playgroud)

消除在执行 ui 测试期间显示的系统警报,但以下“表”不被识别为警报,我无法消除它。

在此输入图像描述

我已经使用 xcode 中的“记录”按钮来获取“现在不”按钮的 ui 坐标:

app.scrollViews.otherElements.buttons["Not now"].tap() 
Run Code Online (Sandbox Code Playgroud)

我在 Xcode 14.3 中遇到了与上述工作表相关的问题。有没有解决方案可以在执行过程中消除这些系统“表”?

chi*_*dro 5

顺便说一下,我们使用以下方法解决了这个问题:

private func eventuallyDismissPasswordAlert(_ app: XCUIApplication) {
   if app.scrollViews.otherElements.buttons["Non ora"].waitForExistence(timeout: 2) {
       tap(app.scrollViews.otherElements.buttons["Non ora"])
       return
   }
   if app.scrollViews.otherElements.buttons["Not Now"].waitForExistence(timeout: 2) {
       tap(app.scrollViews.otherElements.buttons["Not Now"])
       return
   }
}
Run Code Online (Sandbox Code Playgroud)


Mar*_*ann 2

假设您使用的是模拟器或不需要该功能的设备,您可以转到“设置”应用程序并在“密码”“密码选项”下禁用从钥匙串填充密码。这样可以防止床单破裂。

在此输入图像描述

  • 谢谢,抱歉,如果我没有提到这个解决方案,但我想避免这个解决方案,因为它非常耗时/信用,因为我们在连续集成上运行了超过 900 个 ui 测试。我应该为每个 UI 测试将“Autofill pwd”设置为 false。 (2认同)