Webdriver API client.
Summary
Elements
Clears the value of a text input or text area element
Clicks an element
Fetches the currently active (focused) element
Fetches the value of an element's attribute
Sends a request to the server to see if an element is displayed
Fetches the value of an element's property
Fetches the visitble text of an element
Finds the first element using the given search strategy
Finds the elements using the given search strategy
Finds elements that are children of the given element
Sends a sequence of keystrokes to the currently active element.
Sends a sequence of keystrokes to an element
Alerts
Accepts the currently active alert dialog.
Dismisses the currently active alert dialog.
Fetches the text from the currently active alert.
Sends keystrokes to the currently active Javascript prompt dialog.
Functions
Deletes all cookies visible to the current page
Fetches all cookies visible to the current web page.
Fetches server status
Returns the size of the current window
Sets a cookie
Sets the size of the window
Takes a screenshot of the current page.
Sessions
@spec end_session(WebDriverClient.Session.t()) :: :ok | {:error, reason()}
Ends a session
@spec fetch_sessions(WebDriverClient.Config.t()) :: {:ok, [WebDriverClient.Session.t()]} | {:error, reason()}
Returns the list of sessions
@spec start_session(WebDriverClient.Config.t(), map()) :: {:ok, WebDriverClient.Session.t()} | {:error, reason()}
Starts a new session
Elements
@spec clear_element(WebDriverClient.Session.t(), WebDriverClient.Element.t()) :: :ok | {:error, reason()}
Clears the value of a text input or text area element
@spec click_element(WebDriverClient.Session.t(), WebDriverClient.Element.t()) :: :ok | {:error, reason()}
Clicks an element
@spec fetch_active_element(WebDriverClient.Session.t()) :: {:ok, WebDriverClient.Element.t()} | {:error, reason()}
Fetches the currently active (focused) element
@spec fetch_element_attribute( WebDriverClient.Session.t(), WebDriverClient.Element.t(), attribute_name() ) :: {:ok, String.t()} | {:error, reason()}
Fetches the value of an element's attribute
@spec fetch_element_displayed( WebDriverClient.Session.t(), WebDriverClient.Element.t() ) :: {:ok, boolean()} | {:error, reason()}
Sends a request to the server to see if an element is displayed
@spec fetch_element_property( WebDriverClient.Session.t(), WebDriverClient.Element.t(), property_name() ) :: {:ok, String.t()} | {:error, reason()}
Fetches the value of an element's property
Only supported using :w3c protocol.
@spec fetch_element_text(WebDriverClient.Session.t(), WebDriverClient.Element.t()) :: {:ok, String.t()} | {:error, reason()}
Fetches the visitble text of an element
@spec find_element( WebDriverClient.Session.t(), element_location_strategy(), element_selector() ) :: {:ok, WebDriverClient.Element.t()} | {:error, reason()}
Finds the first element using the given search strategy
If no element is found, a WebDriverClient.WebDriverError
is returned
@spec find_elements( WebDriverClient.Session.t(), element_location_strategy(), element_selector() ) :: {:ok, [WebDriverClient.Element.t()]} | {:error, reason()}
Finds the elements using the given search strategy
@spec find_elements_from_element( WebDriverClient.Session.t(), WebDriverClient.Element.t(), element_location_strategy(), element_selector() ) :: {:ok, [WebDriverClient.Element.t()] | {:error, reason()}}
Finds elements that are children of the given element
@spec send_keys(WebDriverClient.Session.t(), keys()) :: :ok | {:error, reason()}
Sends a sequence of keystrokes to the currently active element.
Only supported with :jwp protocol. Prefer send_keys_to_element/3 for
improved compatibility.
@spec send_keys_to_element( WebDriverClient.Session.t(), WebDriverClient.Element.t(), keys() ) :: :ok | {:error, reason()}
Sends a sequence of keystrokes to an element
Alerts
@spec accept_alert(WebDriverClient.Session.t()) :: :ok | {:error, reason()}
Accepts the currently active alert dialog.
Usually this is the equivalent to clicking ok on a dialog.
@spec dismiss_alert(WebDriverClient.Session.t()) :: :ok | {:error, reason()}
Dismisses the currently active alert dialog.
For confirm() and prompt() dialogs, this is equivalent to
clicking the 'Cancel' button. For alert() dialogs, this is
equivalent to clicking the 'OK' button.
@spec fetch_alert_text(WebDriverClient.Session.t()) :: :ok | {:error, reason()}
Fetches the text from the currently active alert.
@spec send_alert_text(WebDriverClient.Session.t(), String.t()) :: :ok | {:error, reason()}
Sends keystrokes to the currently active Javascript prompt dialog.
Logging
@spec fetch_log_types(WebDriverClient.Session.t()) :: {:ok, [log_type()]} | {:error, reason()}
Fetches the log types from the server
@spec fetch_logs(WebDriverClient.Session.t(), log_type()) :: {:ok, [WebDriverClient.LogEntry.t()]} | {:error, reason()}
Fetches log entries for the requested log type.
Types
@type attribute_name() :: String.t()
@type basic_reason() :: WebDriverClient.ConnectionError.t() | WebDriverClient.UnexpectedResponseError.t() | WebDriverClient.WebDriverError.t()
@type element_location_strategy() :: :css_selector | :xpath
@type element_selector() :: String.t()
@type key_code() ::
:null
| :cancel
| :help
| :backspace
| :tab
| :clear
| :return
| :enter
| :shift
| :left_shift
| :control
| :left_control
| :alt
| :left_alt
| :pause
| :escape
| :space
| :page_up
| :page_down
| :end
| :home
| :left
| :arrow_left
| :up
| :arrow_up
| :right
| :arrow_right
| :down
| :arrow_down
| :insert
| :delete
| :semicolon
| :equals
| :numpad0
| :numpad1
| :numpad2
| :numpad3
| :numpad4
| :numpad5
| :numpad6
| :numpad7
| :numpad8
| :numpad9
| :multiply
| :add
| :separator
| :subtract
| :decimal
| :divide
| :f1
| :f2
| :f3
| :f4
| :f5
| :f6
| :f7
| :f8
| :f9
| :f10
| :f11
| :f12
| :meta
| :command
| :left_meta
| :right_shift
| :right_control
| :right_alt
| :right_meta
| :numpad_page_up
| :numpad_page_down
| :numpad_end
| :numpad_home
| :numpad_left
| :numpad_up
| :numpad_right
| :numpad_down
| :numpad_insert
| :numpad_delete
@type log_type() :: String.t()
@type property_name() :: String.t()
@type protocol() :: WebDriverClient.Config.protocol()
@type reason() :: WebDriverClient.ProtocolMismatchError.t() | basic_reason()
@type set_cookie_opt() :: {:domain, WebDriverClient.Cookie.domain()}
@type size_opt() :: {:width, pos_integer()} | {:height, pos_integer()}
@type url() :: String.t()
Functions
@spec delete_cookies(WebDriverClient.Session.t()) :: :ok | {:error, reason()}
Deletes all cookies visible to the current page
@spec fetch_cookies(WebDriverClient.Session.t()) :: {:ok, [WebDriverClient.Cookie.t()]} | {:error, reason()}
Fetches all cookies visible to the current web page.
@spec fetch_server_status(WebDriverClient.Config.t()) :: {:ok, WebDriverClient.ServerStatus.t()} | {:error, reason()}
Fetches server status
@spec fetch_window_size(WebDriverClient.Session.t()) :: {:ok, WebDriverClient.Size.t()} | {:error, reason()}
Returns the size of the current window
@spec set_cookie( WebDriverClient.Session.t(), WebDriverClient.Cookie.name(), WebDriverClient.Cookie.value(), [set_cookie_opt()] ) :: :ok | {:error, reason()}
Sets a cookie
@spec set_window_size(WebDriverClient.Session.t(), [size_opt()]) :: :ok | {:error, reason()}
Sets the size of the window
@spec take_screenshot(WebDriverClient.Session.t()) :: {:ok, binary()} | {:error, reason()}
Takes a screenshot of the current page.