web_driver_client v0.2.0 WebDriverClient View Source

Webdriver API client.

Link to this section Summary

Sessions

Ends a session

Returns the list of sessions

Starts a new session

Navigation

Returns the web browsers current url

Returns page source of the top-most window.

Returns page title of the top-most window.

Navigates the browser to the given url

Elements

Clears the value of a text input or text area 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

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.

Logging

Fetches the log types from the server

Fetches log entries for the requested log type.

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 the size of the window

Takes a screenshot of the current page.

Link to this section Types

Link to this type

attribute_name()

View Source
attribute_name() :: String.t()
Link to this type

element_location_strategy()

View Source
element_location_strategy() :: :css_selector | :xpath
Link to this type

element_selector()

View Source
element_selector() :: String.t()
Link to this type

key_code()

View Source
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
Link to this type

keystroke()

View Source
keystroke() :: String.t() | key_code()
Link to this type

log_type()

View Source
log_type() :: String.t()
Link to this type

property_name()

View Source
property_name() :: String.t()
Link to this type

size_opt()

View Source
size_opt() :: {:width, pos_integer()} | {:height, pos_integer()}

Link to this section Sessions

Link to this function

end_session(session)

View Source
end_session(WebDriverClient.Session.t()) :: :ok | {:error, reason()}

Ends a session

Link to this function

fetch_sessions(config)

View Source
fetch_sessions(WebDriverClient.Config.t()) ::
  {:ok, [WebDriverClient.Session.t()]} | {:error, reason()}

Returns the list of sessions

Link to this function

start_session(config, payload)

View Source
start_session(WebDriverClient.Config.t(), map()) ::
  {:ok, WebDriverClient.Session.t()} | {:error, reason()}

Starts a new session

Link to this section Elements

Link to this function

clear_element(session, element)

View Source
clear_element(WebDriverClient.Session.t(), WebDriverClient.Element.t()) ::
  :ok | {:error, reason()}

Clears the value of a text input or text area element

Link to this function

click_element(session, element)

View Source
click_element(WebDriverClient.Session.t(), WebDriverClient.Element.t()) ::
  :ok | {:error, reason()}

Clicks an element

Link to this function

fetch_active_element(session)

View Source
fetch_active_element(WebDriverClient.Session.t()) ::
  {:ok, WebDriverClient.Element.t()} | {:error, reason()}

Fetches the currently active (focused) element

Link to this function

fetch_element_attribute(session, element, attribute_name)

View Source
fetch_element_attribute(
  WebDriverClient.Session.t(),
  WebDriverClient.Element.t(),
  attribute_name()
) :: {:ok, String.t()} | {:error, reason()}

Fetches the value of an element's attribute

Link to this function

fetch_element_displayed(session, element)

View Source
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

Link to this function

fetch_element_property(session, element, property_name)

View Source
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.

Link to this function

fetch_element_text(session, element)

View Source
fetch_element_text(WebDriverClient.Session.t(), WebDriverClient.Element.t()) ::
  {:ok, String.t()} | {:error, reason()}

Fetches the visitble text of an element

Link to this function

find_element(session, element_location_strategy, element_selector)

View Source

Finds the first element using the given search strategy

If no element is found, a WebDriverClient.WebDriverError is returned

Link to this function

find_elements(session, element_location_strategy, element_selector)

View Source

Finds the elements using the given search strategy

Link to this function

find_elements_from_element(session, element, element_location_strategy, element_selector)

View Source

Finds elements that are children of the given element

Link to this function

send_keys(session, keys)

View Source
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.

Link to this function

send_keys_to_element(session, element, keys)

View Source
send_keys_to_element(
  WebDriverClient.Session.t(),
  WebDriverClient.Element.t(),
  keys()
) :: :ok | {:error, reason()}

Sends a sequence of keystrokes to an element

Link to this section Alerts

Link to this function

accept_alert(session)

View Source
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.

Link to this function

dismiss_alert(session)

View Source
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.

Link to this function

fetch_alert_text(session)

View Source
fetch_alert_text(WebDriverClient.Session.t()) :: :ok | {:error, reason()}

Fetches the text from the currently active alert.

Link to this function

send_alert_text(session, text)

View Source
send_alert_text(WebDriverClient.Session.t(), String.t()) ::
  :ok | {:error, reason()}

Sends keystrokes to the currently active Javascript prompt dialog.

Link to this section Logging

Link to this function

fetch_log_types(session)

View Source
fetch_log_types(WebDriverClient.Session.t()) ::
  {:ok, [log_type()]} | {:error, reason()}

Fetches the log types from the server

Link to this function

fetch_logs(session, log_type)

View Source
fetch_logs(WebDriverClient.Session.t(), log_type()) ::
  {:ok, [WebDriverClient.LogEntry.t()]} | {:error, reason()}

Fetches log entries for the requested log type.

Link to this section Functions

Link to this function

delete_cookies(session)

View Source
delete_cookies(WebDriverClient.Session.t()) :: :ok | {:error, reason()}

Deletes all cookies visible to the current page

Link to this function

fetch_cookies(session)

View Source
fetch_cookies(WebDriverClient.Session.t()) ::
  {:ok, [WebDriverClient.Cookie.t()]} | {:error, reason()}

Fetches all cookies visible to the current web page.

Link to this function

fetch_server_status(config)

View Source
fetch_server_status(WebDriverClient.Config.t()) ::
  {:ok, WebDriverClient.ServerStatus.t()} | {:error, reason()}

Fetches server status

Link to this function

fetch_window_size(session)

View Source
fetch_window_size(WebDriverClient.Session.t()) ::
  {:ok, WebDriverClient.Size.t()} | {:error, reason()}

Returns the size of the current window

Link to this function

set_cookie(session, name, value, opts \\ [])

View Source

Sets a cookie

Link to this function

set_window_size(session, opts \\ [])

View Source
set_window_size(WebDriverClient.Session.t(), [size_opt()]) ::
  :ok | {:error, reason()}

Sets the size of the window

Link to this function

take_screenshot(session)

View Source
take_screenshot(WebDriverClient.Session.t()) ::
  {:ok, binary()} | {:error, reason()}

Takes a screenshot of the current page.