Module Make.Error

All potentital errors raised by the WebDriver protocol.

See the WebDriver specification for an explanation of the source of an error:

type error = [
  1. | `element_click_intercepted
  2. | `element_not_interactable
  3. | `insecure_certificate
  4. | `invalid_argument
  5. | `invalid_element_state
  6. | `invalid_selector
  7. | `invalid_session_id
  8. | `javascript_error
  9. | `move_target_out_of_bounds
  10. | `no_such_alert
  11. | `no_such_element
  12. | `no_such_frame
  13. | `no_such_window
  14. | `script_timeout
  15. | `session_not_created
  16. | `stale_element_reference
  17. | `timeout
  18. | `unable_to_capture_screen
  19. | `unexpected_alert_open
  20. | `unknown_command
  21. | `unknown_error
  22. | `unknown_method
  23. | `unsupported_operation
  24. | `unspecified of string
    (*

    browser specific failure

    *)
  25. | `ocaml_protocol_failure
    (*

    a bug in this library, please report!

    *)
]
type t = {
  1. error : error;
    (*

    the WebDriver error

    *)
  2. message : string;
    (*

    a human readable explanation

    *)
  3. stacktrace : string;
    (*

    browser stacktrace

    *)
  4. data : Yojson.Safe.t;
    (*

    additional metadatas

    *)
}
val to_string : t -> string

to_string err returns a debug-friendly string of the WebDriver error.

val catch : (unit -> 'a cmd) -> ?errors:error list -> (t -> 'a cmd) -> 'a cmd

catch (fun () -> cmd) ?errors (fun err -> catch) runs cmd, catching any WebDriver exceptions from ?errors (or all if unspecified), then runs catch if necessary with the error err as an argument.

Some errors are less fatal than others: it's common to catch `no_such_element, sleep and retry when the element in question is created by some (slow) javascript. See Timeouts to add an implicit wait for this situation.

val fail : exn -> 'a cmd

fail e raises the exception e.