Module Make.Wait
Even 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.
val retry : ?max:int -> ?sleep:int -> ?errors:Error.error list -> 'a cmd -> 'a cmdretry cmdattempts to executecmd. 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 themaxtime 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 conditionbehaves likeretry condition, but the predicate must also be satisfied at the end.Raises
`unspecified "condition"if themaxtime 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. *)