0

I have the following piece of code which is:

  • click a toggle from Firefox app
  • the toggle opens the Default apps menu from System settings
  • I open the browser list, pick my browser and return to the app by pressing back.

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"))```
0

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. Same for: mDevice.findObject(UiSelector().text("Firefox Preview"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.