Skip to content

Commit 09c5c53

Browse files
committed
fix: Handle back button click exception
This commit addresses a potential exception when clicking the back button in the UI tests by adding a try-catch block. - If clicking the back button via `backButton.click()` fails, it falls back to using `device.pressBack()`. - Increased the wait time for idle state from 1000ms to 7000ms to ensure the UI has settled after navigating back.
1 parent 44a281b commit 09c5c53

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

benchmarks/src/main/kotlin/com/mshdabiola/benchmarks/detail/DetailActions.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ fun MacrobenchmarkScope.goBack() {
1414
device.wait(Until.hasObject(selector), 5000)
1515

1616
val backButton = device.findObject(selector)
17-
backButton.click()
18-
device.waitForIdle(1000)
17+
try {
18+
backButton.click()
19+
} catch (e: Exception) {
20+
e.printStackTrace()
21+
device.pressBack()
22+
}
23+
device.waitForIdle(7000)
1924
// Wait until saved title are shown on screen
2025
}
2126

0 commit comments

Comments
 (0)