Android 浓缩咖啡/UIAutomator测试-无法找到/排除“;使用Google“自动填充”保存密码;对话
我们正在FireBase测试实验室进行浓缩咖啡测试。我注意到某些设备(如LG Nexus 5)的测试失败,原因是在登录应用程序后出现了一个错误。我想处理(取消)这个弹出窗口。我可以在我们拥有的真实设备上关闭此功能,但在TestLab上,此功能有时是打开的,我认为我无法关闭它(或者我可以?)。我试过很多方法: 尝试用浓缩咖啡定位-不起作用(我猜,因为它不是应用程序的一部分): 尝试单击“上一步”并再次启动“活动”,弹出窗口仍然存在(尽管手动单击关闭) 试图用UIAutomator通过多个选择器找到它-不起作用。 UIAutomatorViewer未看到此弹出窗口。AndroidStudio监视器也看不到此弹出窗口。谷歌似乎将其作为信息信息发送。有没有一种方法可以通过编程消除它?也许有办法发送adb命令来关闭它?非常感谢您的指导。在以下位置复制: 我有幸在浓缩咖啡测试期间禁用了自动填充功能,并在输入文本时应用了自定义ViewActionsAndroid 浓缩咖啡/UIAutomator测试-无法找到/排除“;使用Google“自动填充”保存密码;对话,android,popup,android-espresso,autofill,android-uiautomator,Android,Popup,Android Espresso,Autofill,Android Uiautomator,我们正在FireBase测试实验室进行浓缩咖啡测试。我注意到某些设备(如LG Nexus 5)的测试失败,原因是在登录应用程序后出现了一个错误。我想处理(取消)这个弹出窗口。我可以在我们拥有的真实设备上关闭此功能,但在TestLab上,此功能有时是打开的,我认为我无法关闭它(或者我可以?)。我试过很多方法: 尝试用浓缩咖啡定位-不起作用(我猜,因为它不是应用程序的一部分): 尝试单击“上一步”并再次启动“活动”,弹出窗口仍然存在(尽管手动单击关闭) 试图用UIAutomator通过多个选择器找到
.onView(...)
.perform(
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return Matchers.any(View.class);
}
@Override
public String getDescription() {
return "Marking view not important for autofill";
}
@Override
public void perform(UiController uiController, View view) {
// Required to disable autofill suggestions during tests on API 26+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
}
}
})
.perform(click())
.perform(clearText())
.perform(typeText(textToType))
.perform(
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return Matchers.any(View.class);
}
@Override
public String getDescription() {
return "Dismissing autofill picker";
}
@Override
public void perform(UiController uiController, View view) {
// Required to dismiss the autofill picker during tests on API 26+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AutofillManager autofillManager =
view.getContext()
.getSystemService(AutofillManager.class);
if (autofillManager != null) autofillManager.cancel();
}
}
});
.onView(…)
.表演(
新建ViewAction(){
@凌驾
公共匹配器getConstraints(){
返回Matchers.any(View.class);
}
@凌驾
公共字符串getDescription(){
返回“标记视图对自动填充不重要”;
}
@凌驾
公共作废执行(UiController UiController,视图){
//在API 26测试期间禁用自动填充建议需要+
if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.O){
view.setImportantForAutofill(view.importantforautofill\u编号的view.IMPORTANT\u);
}
}
})
.执行(单击())
.perform(clearText())
.perform(typeText(textToType))
.表演(
新建ViewAction(){
@凌驾
公共匹配器getConstraints(){
返回Matchers.any(View.class);
}
@凌驾
公共字符串getDescription(){
返回“解除自动填充选择器”;
}
@凌驾
公共作废执行(UiController UiController,视图){
//要求在API 26测试期间关闭自动填充选择器+
if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.O){
自动填充管理器自动填充管理器=
view.getContext()
.getSystemService(AutofillManager.class);
如果(autofillManager!=null)autofillManager.cancel();
}
}
});
Espreso.pressBack();
ActivityTestRule.launchActivity(null);
.onView(...)
.perform(
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return Matchers.any(View.class);
}
@Override
public String getDescription() {
return "Marking view not important for autofill";
}
@Override
public void perform(UiController uiController, View view) {
// Required to disable autofill suggestions during tests on API 26+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
}
}
})
.perform(click())
.perform(clearText())
.perform(typeText(textToType))
.perform(
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return Matchers.any(View.class);
}
@Override
public String getDescription() {
return "Dismissing autofill picker";
}
@Override
public void perform(UiController uiController, View view) {
// Required to dismiss the autofill picker during tests on API 26+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AutofillManager autofillManager =
view.getContext()
.getSystemService(AutofillManager.class);
if (autofillManager != null) autofillManager.cancel();
}
}
});