commit 6fd4349af29d81513fede0631edd7407191fbd08
parent cc21229a2117c18751ff675549555cad45fa36d9
Author: AndiAJ <andiaj@users.noreply.github.com>
Date: Thu, 6 Nov 2025 15:25:58 +0000
Bug 1996200 - Fix verifySelectAllPDFTextOptionTest UI test r=aaronmt
The UI test was flaky because it sometimes failed to click the "Paste" option.
To fix this, I've added a retry loop.
The UI test successfully without the **retryTestRule** passed 50x on Firebase ✅
Differential Revision: https://phabricator.services.mozilla.com/D271581
Diffstat:
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/TextSelectionTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/TextSelectionTest.kt
@@ -5,9 +5,7 @@
package org.mozilla.fenix.ui
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
-import androidx.test.filters.SdkSuppress
import mozilla.components.feature.sitepermissions.SitePermissionsRules
-import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt
@@ -521,12 +521,31 @@ class SearchRobot {
}
fun clickPasteText() {
- Log.i(TAG, "clickPasteText: Waiting for $waitingTimeShort ms for the \"Paste\" option to exist")
- mDevice.findObject(UiSelector().textContains("Paste")).waitForExists(waitingTimeShort)
- Log.i(TAG, "clickPasteText: Waited for $waitingTimeShort ms for the \"Paste\" option to exist")
- Log.i(TAG, "clickPasteText: Trying to click the \"Paste\" button")
- mDevice.findObject(By.textContains("Paste")).click()
- Log.i(TAG, "clickPasteText: Clicked the \"Paste\" button")
+ for (i in 1..RETRY_COUNT) {
+ Log.i(TAG, "clickPasteText: Started try #$i")
+ try {
+ Log.i(TAG, "clickPasteText: Waiting for $waitingTime ms for the \"Paste\" option to exist")
+ mDevice.findObject(UiSelector().textContains("Paste")).waitForExists(waitingTime)
+ Log.i(TAG, "clickPasteText: Waited for $waitingTime ms for the \"Paste\" option to exist")
+ Log.i(TAG, "clickPasteText: Trying to click the \"Paste\" button")
+ mDevice.findObject(By.textContains("Paste")).click()
+ Log.i(TAG, "clickPasteText: Clicked the \"Paste\" button")
+
+ break
+ } catch (e: NullPointerException) {
+ Log.i(TAG, "clickPasteText: NullPointerException caught, executing fallback methods")
+ if (i == RETRY_COUNT) {
+ throw e
+ } else {
+ searchScreen {
+ }.dismissSearchBar {
+ }.openSearch {
+ clickClearButton()
+ longClickToolbar()
+ }
+ }
+ }
+ }
}
fun verifyTranslatedFocusedNavigationToolbar(toolbarHintString: String) =