Webdriver_cohttp_async.WaitEven though the browser attempts to complete most operations before giving back control, some commands might trigger too soon and raise an error. The recommended strategy is to sleep and retry the operation repeatedly until it succeeds.
The default parameters are:
?sleep = 50ms is the amount of time to sleep before retrying the command.?max = 3000ms is the maximum total time spend waiting in between retries (in milliseconds).?errors are the recoverable errors. By default:[ `element_not_interactable
; `invalid_element_state
; `move_target_out_of_bounds
; `no_such_alert
; `no_such_cookie
; `no_such_element
; `no_such_frame
; `no_such_window
]The others WebDriver errors are more indicative of an issue in your automation script.
val retry :
?max:int ->
?sleep:int ->
?errors:Error.error list ->
'a cmd ->
'a cmdretry cmd attempts to execute cmd. If it fails with a recoverable error, the execution sleeps for a bit to give the browser a chance to catch up, then the operation is retried until it succeeds or the max time is reached.
let* e = find_first `css "#id" in (* might raise `no_such_element *)
(* vs *)
let* e = Wait.retry @@ find_first `css "#id" in (* deterministic *)val until :
?max:int ->
?sleep:int ->
?errors:Error.error list ->
bool cmd ->
unit cmduntil condition behaves like retry condition, but the predicate must also be satisfied at the end.
Raises `unspecified "condition" if the max time is reached and the condition is still unsatisfied.
let* url = current_url in
let* () = send_keys input ("hello" ^ Key.Enter) in
let* () = Wait.until @@ map (( <> ) url ) current_url in
(* blocks until the form is actually submitted. *)