Module Wd.Connection

WebDriver connections.

A WebDriver connection abstracts over driver process spawns (if any) and the WebSocket-based communication protocol.

module Config : sig ... end

Driver configuration.

type custom = Config.t -> (Webs.Url.t * (unit -> (unit, string) Stdlib.result), string) Stdlib.result

The type for custom drivers.

Given a configuration which the driver should try to abide by, possibly erroring if it can't, the function must return an URL on which to perform the WebSocket handshake and a function to invoke on close to teardown the driver after the WebSocket has been closed.

type driver =
  1. | Chrome
  2. | Edge
  3. | Firefox
  4. | Safari
  5. | Custom of custom

The type for browser drivers.

type t

The type for WebDriver BiDi connections.

val open' : ?config:Config.t -> driver -> (t, string) Stdlib.result

open' driver opens a connection using driver driver. Connections are ressources, they must eventually be closed by close. config defaults to Config.make ().

val close : t -> (unit, string) Stdlib.result

close c closes the connection. The function does not raise.

val handle : t -> (unit -> 'a) -> 'a

handle c f handles the command and event asynchrony of the protocol in function f, any use of a connection c must be wrapped by this function.

val with_open : ?config:Config.t -> driver -> (t -> 'a) -> ('a, string) Stdlib.result

with_open driver f executes handle c (fun () -> f c) with c an open connection on driver. If f raises Webs_webdriver.Wd.Error it is turned into an Error value.

Properties

val config : t -> Config.t

config c is the configuration that was used when opening c.

val driver : t -> driver

driver c is the driver of the underlying connection.

val url : t -> Webs.Url.t

url c is the URL on which the WebSocket handshake was performed.