Espresso 测试:以编程方式在智能锁保存密码上选择“从不”

Jas*_*son 6 android android-espresso google-signin google-smartlockpasswords

在 Android 上进行 espresso UI 测试并尝试绕过智能锁屏幕。问题是我们正在 Firebase 中进行测试,并且无法关闭整个设备上的智能锁,因为它们位于云中(我不相信)。弹出窗口也不是应用程序本身的一部分,因此我无法使用 Stetho 或布局检查器获取 id。我相信这是在我们的应用程序之上绘制的另一个应用程序(或操作系统功能)。

如何在浓缩咖啡中按下“不,谢谢”或“从不”按钮?

智能锁

小智 1

您可以使用 uiautomator

梯度

androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
Run Code Online (Sandbox Code Playgroud)

并将其添加到您的代码中:

waitSeconds(10) // Waiting for smartlock window
val uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val currentPackageName = uiDevice.currentPackageName
if (currentPackageName != "your.app.package") {
     uiDevice.pressBack()
}
Run Code Online (Sandbox Code Playgroud)