From e4d13d32260fd8cf7f5e8e075474a9609b9dfa4a Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Tue, 17 May 2022 15:45:44 +0300 Subject: [PATCH] For #25184 and #23417 fix flaky testDownloadPrompt and testCloseDownloadPrompt --- .../mozilla/fenix/ui/robots/DownloadRobot.kt | 40 ++++++++++++++----- .../taskcluster/androidTest/flank-x86.yml | 4 +- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt index 5687dcb7cc14..cc6d167c5e8f 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt @@ -133,16 +133,36 @@ fun downloadRobot(interact: DownloadRobot.() -> Unit): DownloadRobot.Transition } private fun assertDownloadPrompt(fileName: String) { - assertTrue( - "Download prompt button not visible", - mDevice.findObject(UiSelector().resourceId("$packageName:id/download_button")) - .waitForExists(waitingTime) - ) - assertTrue( - "$fileName title doesn't match", - mDevice.findObject(UiSelector().text(fileName)) - .waitForExists(waitingTime) - ) + var currentTries = 0 + while (currentTries++ < 3) { + try { + assertTrue( + "Download prompt button not visible", + mDevice.findObject(UiSelector().resourceId("$packageName:id/download_button")) + .waitForExists(waitingTime) + ) + assertTrue( + "$fileName title doesn't match", + mDevice.findObject(UiSelector().text(fileName)) + .waitForExists(waitingTime) + ) + } catch (e: AssertionError) { + browserScreen { + }.clickDownloadLink(fileName) { + } + + assertTrue( + "Download prompt button not visible", + mDevice.findObject(UiSelector().resourceId("$packageName:id/download_button")) + .waitForExists(waitingTime) + ) + assertTrue( + "$fileName title doesn't match", + mDevice.findObject(UiSelector().text(fileName)) + .waitForExists(waitingTime) + ) + } + } } private fun assertDownloadNotificationPopup() { diff --git a/automation/taskcluster/androidTest/flank-x86.yml b/automation/taskcluster/androidTest/flank-x86.yml index 4226b9a209d0..b56a79d8691c 100644 --- a/automation/taskcluster/androidTest/flank-x86.yml +++ b/automation/taskcluster/androidTest/flank-x86.yml @@ -40,6 +40,8 @@ gcloud: test-targets: - notPackage org.mozilla.fenix.screenshots - notPackage org.mozilla.fenix.syncintegration + - class org.mozilla.fenix.ui.DownloadTest#testDownloadPrompt + - class org.mozilla.fenix.ui.DownloadTest#testCloseDownloadPrompt device: - model: Pixel2 @@ -53,7 +55,7 @@ flank: max-test-shards: -1 # num-test-runs: the amount of times to run the tests. # 1 runs the tests once. 10 runs all the tests 10x - num-test-runs: 1 + num-test-runs: 50 ### Output Style flag ## Output style of execution status. May be one of [verbose, multi, single, compact]. ## For runs with only one test execution the default value is 'verbose', in other cases