I have the following piece of code which is:
This part works fine in my local Android studio emulator and real device, but when I run it on Firebase test lab with the same virtual device configuration: Pixel 2 API 28, it will not detect the "Browser app" text and fail.
Any ideas why it behaves differently on the Firebase virtual device?
fun selectDefaultBrowser() {
clickSetDefaultBrowserToggle()
mDevice.waitNotNull(
Until.findObject(By.text("Browser app")),
TestAssetHelper.waitingTime
)
assertAndroidSettingsPackage()
defaultBrowserAppList().waitForExists(waitingTime)
defaultBrowserAppList().clickAndWaitForNewWindow()
fenixDebugOption().click()
mDevice.pressBack()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mDevice.pressBack()
}
}
fun clickSetDefaultBrowserToggle() =
setDefaultBrowserToggle().clickAndWaitForNewWindow()
fun setDefaultBrowserToggle() = mDevice.findObject(
UiSelector().resourceId("org.mozilla.fenix.debug:id/switch_widget")
)
fun defaultBrowserAppList() = mDevice.findObject(
(UiSelector()
.className("android.widget.TextView"))
.resourceId("android:id/title")
.text("Browser app")
)
fun assertAndroidSettingsPackage() = assertTrue(
mDevice.findObject(
(UiSelector().packageName("com.android.settings"))
).waitForExists(waitingTime)
)
fun fenixDebugOption() = mDevice.findObject(UiSelector().text("Firefox Preview"))```
Found the culprit.This is not enough: fun defaultBrowserAppList() = mDevice.findObject((UiSelector().text("Browser app")). For some reason it doesn't match the text.
Should be replaced with UiSelector().textContains("Browser app") and then it works (ignores caps/non-caps). Same for: mDevice.findObject(UiSelector().textContains("Firefox Preview"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.