gpt4 book ai didi

android - 如何从 Android Oreo 禁用新的自动填充功能以进行 Espresso 测试

转载 作者:IT王子 更新时间:2023-10-28 23:31:52 26 4
gpt4 key购买 nike

使用 sdk 26 在 android 设备上运行测试会导致测试失败,因为新的 Autofill当 espresso 尝试点击字段时隐藏字段的功能。

我在 firebase 测试实验室运行我的测试,所以我无法在我的测试设备上手动禁用它们。

一些图片:

1。在点击用户名字段之前,密码是可见的。

enter image description here

2。单击用户名字段后,密码字段被此自动填充对话框隐藏:

enter image description here

3。登录后会显示另一个填充对话框:

enter image description here

Espresso 现在无法单击密码字段,因为自动填充对话框隐藏了我的字段并且 fail

使用 AutofillManager#disableAutofillServices() 仅禁用了 #2。对话框,但 #3。还在。

如何在测试设备上禁用自动填充?

最佳答案

根据文档,您可以使用 AutofillManager#disableAutofillServices() 禁用自动填充服务接口(interface):

If the app calling this API has enabled autofill services they will be disabled.

用法:


val autofillManager: AutofillManager = context.getSystemService(AutofillManager::class.java)
autofillManager.disableAutofillServices()

您可以在测试的 @Before 步骤中执行此操作。

关于android - 如何从 Android Oreo 禁用新的自动填充功能以进行 Espresso 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46812716/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com