commit fc12f82a1d2c64219e9f7288edd65d0b0feb3558
parent 14c08f0368ead8bfdddec62f43e0bb5c8fd61289
Author: AndiAJ <andiaj@users.noreply.github.com>
Date: Mon, 22 Dec 2025 17:05:47 +0000
Bug 1960705 - Fix verifyWebCompatPageIsLoadingTest UI test r=mcarare
The UI test was flaky because it sometimes it could interact properly with the web compat page items.
To fix this I've updated the way we query the elements.
The UI test successfully passed 75x on Firebase ✅
Differential Revision: https://phabricator.services.mozilla.com/D277334
Diffstat:
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/helpers/MatcherHelper.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/helpers/MatcherHelper.kt
@@ -54,6 +54,11 @@ object MatcherHelper {
return mDevice.findObject(UiSelector().resourceId(resourceId).index(index))
}
+ fun itemWithTextAndIndex(itemText: String, index: Int): UiObject {
+ Log.i(TAG, "Looking for item with text: $itemText and index: $index")
+ return mDevice.findObject(UiSelector().text(itemText).index(index))
+ }
+
fun itemWithClassNameAndContainingDescription(className: String, description: String): UiObject {
Log.i(TAG, "Looking for item with class name: $className and description: $description")
return mDevice.findObject(UiSelector().className(className).descriptionContains(description))
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt
@@ -69,6 +69,7 @@ import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
+import org.mozilla.fenix.helpers.MatcherHelper.itemWithTextAndIndex
import org.mozilla.fenix.helpers.SessionLoadedIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong
@@ -1359,7 +1360,8 @@ class BrowserRobot(private val composeTestRule: ComposeTestRule) {
}
fun clickWebCompatPageItem(itemText: String) {
- clickPageObject(this@BrowserRobot.composeTestRule, itemContainingText(itemText))
+ clickPageObject(composeTestRule, itemWithTextAndIndex(itemText, 0))
+ waitForAppWindowToBeUpdated()
}
class Transition(private val composeTestRule: ComposeTestRule) {