Skip to content

Commit

Permalink
For mozilla-mobile#25184 and mozilla-mobile#23417 fix flaky testDownl…
Browse files Browse the repository at this point in the history
…oadPrompt and testCloseDownloadPrompt
  • Loading branch information
AndiAJ committed May 23, 2022
1 parent 672510f commit ff78493
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,29 @@ 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)
)

break
} catch (e: AssertionError) {
println("Failed to find locator: ${e.localizedMessage}")

browserScreen {
}.clickDownloadLink(fileName) {
}
}
}
}

private fun assertDownloadNotificationPopup() {
Expand Down

0 comments on commit ff78493

Please sign in to comment.