Skip to content

Commit

Permalink
Wait longer.
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Aug 22, 2024
1 parent b0b7553 commit 495a31e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 11 additions & 2 deletions tests/webdriver-test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,19 @@ build-xml-request -> string
}
"""

get-text driver/WebDriver --id/string -> string:
for i := 0; i < 10; i++:
driver-ids := driver.find "#id"
if driver-ids.is-empty:
sleep --ms=(10 * i)
continue
return driver.get-text driver-ids.first
throw "Timeout waiting for element with id '$id'"

expect-ok path/string driver/WebDriver -> none:
driver.goto "$URL/$path"
for i := 0; i < 10; i++:
text := driver.get-text --id="status"
text := get-text driver --id="status"
if text != "Pending":
expect-equals "OK" text
return
Expand Down Expand Up @@ -249,7 +258,7 @@ test-form driver/WebDriver path/string -> none:
driver.goto "$URL/$path"
id := driver.find "#submit"
driver.click id.first
expect-equals "OK" (driver.get-text --id="status")
expect-equals "OK" (get-text driver --id="status")

test-post-form driver/WebDriver -> none:
test-form driver "test-post-form"
Expand Down
9 changes: 3 additions & 6 deletions tests/webdriver.toit
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,16 @@ class WebDriver:
goto url/string:
post_ "url" { "url": url }

find css-selector/string -> List?:
find css-selector/string -> List:
response := post_ "element" { "using": "css selector", "value": css-selector }
element-json := response["value"]
if element-json.contains "error": return null
if not element-json: return null
if element-json.contains "error": return []
if not element-json: return []
return element-json.values

get-text element-id/string -> string:
response := get_ "element/$element-id/text"
return response["value"]

get-text --id/string -> string:
return get-text (find "#$id").first

click element-id/string:
post_ "element/$element-id/click" {:}

0 comments on commit 495a31e

Please sign in to comment.