Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeout unit in ScrollUntilVisibleCommand #2112

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions e2e/workspaces/demo_app/scrollUntilVisible_timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
appId: com.example.example
tags:
- passing
---
- launchApp:
clearState: true
- evalScript: ${maestro.startTime = new Date()}
- scrollUntilVisible:
element: non-existent
timeout: 1000
optional: true
- evalScript: ${maestro.endTime = new Date()}
- evalScript: ${"scrollUntilVisible took " + console.log(maestro.endTime - maestro.startTime) + "ms"}
- assertTrue: ${maestro.endTime - maestro.startTime < 5000} # Far less than the 20000 default, but enough to allow for processing time
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"
}
}
Loading