Doing espresso UI testing on Android and trying to bypass the smart lock screen. Issue is that we are testing in Firebase, and cannot turn off smart lock on the device as a whole since they are in the cloud (I don't believe). The popup is also not a part of the app itself, so I can't get the id using Stetho or Layout inspector. I believe it's another app (or OS feature) drawing on top of our app.
How can I hit the "no thanks" or "never" button in espresso?
答案 0 :(得分:0)
您可以使用uiautomator
<强> graddle 强>:
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
并将其添加到代码:
waitSeconds(10) // Waiting for smartlock window
val uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val currentPackageName = uiDevice.currentPackageName
if (currentPackageName != "your.app.package") {
uiDevice.pressBack()
}