Skip to content

Commit

Permalink
Try to fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltroger committed May 1, 2024
1 parent f17627e commit 294e168
Showing 1 changed file with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AndroidFileAppRobot {

fun openPdf(fileName: String): MainActivityRobot {
selectFile(fileName = fileName, longClick = false)
uiDevice.wait(Until.hasObject(greenPassSelector), TIMEOUT)
return MainActivityRobot()
}

Expand All @@ -73,26 +74,16 @@ class AndroidFileAppRobot {
val uiScrollable = UiScrollable(UiSelector().scrollable(true))
val selector = By.text(fileName)

(1..RETRIALS).forEach { _ ->
try {
if (uiDevice.hasObject(greenPassSelector)) {
return
}

uiScrollable.scrollTextIntoView(fileName)

uiDevice.wait(Until.hasObject(selector), TIMEOUT)

if (longClick) {
uiDevice.findObject(selector).longClick()
} else {
uiDevice.findObject(selector).click()
}
uiDevice.wait(Until.hasObject(selector), TIMEOUT)
if (!uiDevice.hasObject(selector)) {
uiScrollable.scrollForward(1)
uiDevice.wait(Until.hasObject(selector), TIMEOUT)
}

uiDevice.wait(Until.hasObject(greenPassSelector), TIMEOUT)
} catch (e: NullPointerException) {
//ignoring
}
if (longClick) {
uiDevice.findObject(selector).longClick()
} else {
uiDevice.findObject(selector).click()
}
}

Expand Down

0 comments on commit 294e168

Please sign in to comment.