Skip to content

Commit

Permalink
Fix timeout unit in ScrollUntilVisibleCommand
Browse files Browse the repository at this point in the history
The `timeout` in ScrollUntilVisibleCommand should be interpreted as milliseconds: https://maestro.mobile.dev/api-reference/commands/scrolluntilvisible

Fixes mobile-dev-inc#2108.
This was broken by mobile-dev-inc#2023.
  • Loading branch information
vibin committed Oct 23, 2024
1 parent e957c5e commit 19404ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ data class ScrollUntilVisibleCommand(
}

private fun String.timeoutToMillis(): String {
val timeout = if (this.toLong() < 0) { DEFAULT_TIMEOUT_IN_MILLIS.toLong() * 1000L } else this.toLong() * 1000L
return timeout.toString()
return if (this.toLong() < 0) { DEFAULT_TIMEOUT_IN_MILLIS } else this
}

override fun description(): String {
Expand All @@ -132,7 +131,7 @@ data class ScrollUntilVisibleCommand(
}

companion object {
const val DEFAULT_TIMEOUT_IN_MILLIS = "20"
const val DEFAULT_TIMEOUT_IN_MILLIS = "20000"
const val DEFAULT_SCROLL_DURATION = "40"
const val DEFAULT_ELEMENT_VISIBILITY_PERCENTAGE = 100
const val DEFAULT_CENTER_ELEMENT = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ internal class YamlCommandReaderTest {
ScrollUntilVisibleCommand(
selector = ElementSelector(textRegex = "Footer"),
direction = ScrollDirection.DOWN,
timeout = "20",
timeout = "20000",
scrollDuration = "40",
visibilityPercentage = 100,
label = "Scroll to the bottom",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ output.speed = {
}

output.timeout = {
slow: 20
slow: 20000
}

output.element = {
id: "maestro"
}
}

0 comments on commit 19404ff

Please sign in to comment.