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 05fcd5f commit f17627e
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class AndroidFileAppRobot {

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

Expand All @@ -76,26 +72,27 @@ class AndroidFileAppRobot {

val uiScrollable = UiScrollable(UiSelector().scrollable(true))
val selector = By.text(fileName)
run loop@{
(1..RETRIALS).forEach { _ ->
try {
if (uiDevice.hasObject(selector)) {
return@loop
}

uiScrollable.scrollTextIntoView(fileName)

uiDevice.wait(Until.hasObject(selector), TIMEOUT)
} catch (e: NullPointerException) {
//ignoring

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

if (longClick) {
uiDevice.findObject(selector).longClick()
} else {
uiDevice.findObject(selector).click()
uiScrollable.scrollTextIntoView(fileName)

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

if (longClick) {
uiDevice.findObject(selector).longClick()
} else {
uiDevice.findObject(selector).click()
}

uiDevice.wait(Until.hasObject(greenPassSelector), TIMEOUT)
} catch (e: NullPointerException) {
//ignoring
}
}
}

Expand Down

0 comments on commit f17627e

Please sign in to comment.