Cerberus.Options (cerberus v0.1.7)

Copy Markdown View Source

Shared option and option-schema types used by Cerberus public APIs and drivers.

This module centralizes validation and normalized defaults for operation option lists (click, fill_in, assert_has, submit, and related helpers).

Summary

Types

assert_download_opts()

@type assert_download_opts() :: [{:timeout, pos_integer()}]

assert_opts()

@type assert_opts() :: [
  visible: visibility_filter(),
  timeout: non_neg_integer(),
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter()
]

assert_value_opts()

@type assert_value_opts() :: [
  timeout: non_neg_integer(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

between_filter()

@type between_filter() :: {non_neg_integer(), non_neg_integer()} | Range.t() | nil

browser_assert_dialog_opts()

@type browser_assert_dialog_opts() :: [timeout: pos_integer(), browser: keyword()]

browser_clear_cookies_opts()

@type browser_clear_cookies_opts() :: [{:timeout, non_neg_integer()}]

browser_drag_opts()

@type browser_drag_opts() :: [{:timeout, non_neg_integer()}]

browser_override_opts()

@type browser_override_opts() :: [
  viewport:
    {pos_integer(), pos_integer()}
    | %{width: pos_integer(), height: pos_integer()}
    | keyword()
    | nil,
  user_agent: String.t() | nil,
  popup_mode: :allow | :same_tab | nil,
  init_script: String.t() | nil,
  init_scripts: [String.t()] | nil,
  ready_timeout_ms: pos_integer() | nil,
  ready_quiet_ms: pos_integer() | nil,
  screenshot_full_page: boolean() | nil,
  screenshot_artifact_dir: String.t() | nil,
  screenshot_path: String.t() | nil,
  bidi_command_timeout_ms: pos_integer() | nil,
  runtime_http_timeout_ms: pos_integer() | nil,
  dialog_timeout_ms: pos_integer() | nil,
  webdriver_url: String.t() | nil,
  chrome_webdriver_url: String.t() | nil,
  headless: boolean() | nil,
  slow_mo: non_neg_integer() | nil,
  chrome_binary: String.t() | nil,
  chromedriver_binary: String.t() | nil,
  chrome_startup_retries: non_neg_integer() | nil,
  chromedriver_log_path: String.t() | nil,
  startup_log_tail_bytes: non_neg_integer() | nil,
  startup_log_tail_lines: non_neg_integer() | nil
]

browser_press_opts()

@type browser_press_opts() :: [{:timeout, non_neg_integer()}]

browser_type_opts()

@type browser_type_opts() :: [clear: boolean(), timeout: non_neg_integer()]

browser_with_popup_opts()

@type browser_with_popup_opts() :: [{:timeout, pos_integer()}]

check_opts()

@type check_opts() :: [
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

choose_opts()

@type choose_opts() :: [
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

click_opts()

@type click_opts() :: [
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

closest_opts()

@type closest_opts() :: [{:from, Cerberus.Locator.t()}]

cookie_same_site_opt()

@type cookie_same_site_opt() :: :strict | :lax | :none | String.t()

count_filter_opts()

@type count_filter_opts() :: [
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

fill_in_opts()

@type fill_in_opts() :: [
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

fill_in_value()

@type fill_in_value() :: String.t() | integer() | float() | boolean()

locator_filter_opts()

@type locator_filter_opts() :: [
  exact: boolean(),
  normalize_ws: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  visible: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil,
  match_by: locator_match_by(),
  has: Cerberus.Locator.t() | nil,
  has_not: Cerberus.Locator.t() | nil
]

locator_leaf_opts()

@type locator_leaf_opts() :: [exact: boolean(), from: Cerberus.Locator.t() | nil]

locator_match_by()

@type locator_match_by() ::
  :text | :label | :link | :button | :placeholder | :title | :alt | :testid

path_match_opts()

@type path_match_opts() :: [{:exact, boolean()}]

path_opts()

@type path_opts() :: [
  exact: boolean(),
  query: path_query(),
  timeout: non_neg_integer()
]

path_query()

@type path_query() :: map() | keyword() | nil

reload_opts()

@type reload_opts() :: visit_opts()

return_result_opts()

@type return_result_opts() :: [{:return_result, boolean()}]

role_locator_name()

@type role_locator_name() :: String.t() | Regex.t() | nil

role_locator_opts()

@type role_locator_opts() :: [
  name: role_locator_name(),
  exact: boolean(),
  from: Cerberus.Locator.t() | nil
]

screenshot_opts()

@type screenshot_opts() :: [
  path: String.t() | nil,
  full_page: boolean(),
  open: boolean(),
  return_result: boolean()
]

select_opts()

@type select_opts() :: [
  option: select_value(),
  exact_option: boolean(),
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

select_value()

@type select_value() :: String.t() | [String.t()]

session_browser_opts()

@type session_browser_opts() :: [
  endpoint: module(),
  timeout_ms: non_neg_integer(),
  ready_timeout_ms: pos_integer(),
  ready_quiet_ms: pos_integer(),
  user_agent: String.t() | nil,
  browser: browser_override_opts(),
  webdriver_url: String.t() | nil,
  chrome_webdriver_url: String.t() | nil,
  chrome_binary: String.t() | nil,
  chromedriver_binary: String.t() | nil,
  chrome_args: [String.t()] | nil,
  headless: boolean() | nil,
  slow_mo: non_neg_integer() | nil,
  chromedriver_port: pos_integer() | nil,
  chrome_startup_retries: non_neg_integer() | nil,
  chromedriver_log_path: String.t() | nil,
  startup_log_tail_bytes: non_neg_integer() | nil,
  startup_log_tail_lines: non_neg_integer() | nil,
  base_url: String.t() | nil
]

session_common_opts()

@type session_common_opts() :: [
  endpoint: module(),
  conn: Plug.Conn.t() | nil,
  timeout_ms: non_neg_integer()
]

state_filter_opts()

@type state_filter_opts() :: [
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  visible: boolean() | nil
]

submit_opts()

@type submit_opts() :: [
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

text_match_opts()

@type text_match_opts() :: [exact: boolean(), normalize_ws: boolean()]

upload_opts()

@type upload_opts() :: [
  timeout: non_neg_integer(),
  force: boolean(),
  checked: boolean() | nil,
  disabled: boolean() | nil,
  selected: boolean() | nil,
  readonly: boolean() | nil,
  count: non_neg_integer() | nil,
  min: non_neg_integer() | nil,
  max: non_neg_integer() | nil,
  between: between_filter(),
  first: boolean(),
  last: boolean(),
  nth: pos_integer() | nil,
  index: non_neg_integer() | nil
]

visibility_filter()

@type visibility_filter() :: boolean() | :any

visit_opts()

@type visit_opts() :: []

Functions

assert_download_schema()

@spec assert_download_schema() :: keyword()

assert_schema()

@spec assert_schema() :: keyword()

assert_value_schema()

@spec assert_value_schema() :: keyword()

browser_assert_dialog_schema()

@spec browser_assert_dialog_schema() :: keyword()

browser_clear_cookies_schema()

@spec browser_clear_cookies_schema() :: keyword()

browser_drag_schema()

@spec browser_drag_schema() :: keyword()

browser_override_schema()

@spec browser_override_schema() :: keyword()

browser_press_schema()

@spec browser_press_schema() :: keyword()

browser_type_schema()

@spec browser_type_schema() :: keyword()

browser_with_popup_schema()

@spec browser_with_popup_schema() :: keyword()

click_schema()

@spec click_schema() :: keyword()

fill_in_schema()

@spec fill_in_schema() :: keyword()

path_schema()

@spec path_schema() :: keyword()

return_result_schema()

@spec return_result_schema() :: keyword()

screenshot_schema()

@spec screenshot_schema() :: keyword()

select_schema()

@spec select_schema() :: keyword()

session_browser_schema()

@spec session_browser_schema() :: keyword()

session_common_schema()

@spec session_common_schema() :: keyword()

submit_schema()

@spec submit_schema() :: keyword()

upload_schema()

@spec upload_schema() :: keyword()

validate_assert!(opts, op_name)

@spec validate_assert!(
  keyword(),
  String.t()
) :: assert_opts()

validate_assert_download!(opts)

@spec validate_assert_download!(keyword()) :: assert_download_opts()

validate_assert_value!(opts, op_name)

@spec validate_assert_value!(
  keyword(),
  String.t()
) :: assert_value_opts()

validate_browser_add_cookie!(opts)

@spec validate_browser_add_cookie!(keyword()) :: browser_add_cookie_opts()

validate_browser_assert_dialog!(opts)

@spec validate_browser_assert_dialog!(keyword()) :: browser_assert_dialog_opts()

validate_browser_clear_cookies!(opts)

@spec validate_browser_clear_cookies!(keyword()) :: browser_clear_cookies_opts()

validate_browser_drag!(opts)

@spec validate_browser_drag!(keyword()) :: browser_drag_opts()

validate_browser_press!(opts)

@spec validate_browser_press!(keyword()) :: browser_press_opts()

validate_browser_type!(opts)

@spec validate_browser_type!(keyword()) :: browser_type_opts()

validate_browser_with_popup!(opts)

@spec validate_browser_with_popup!(keyword()) :: browser_with_popup_opts()

validate_check!(opts, op_name)

@spec validate_check!(
  keyword(),
  String.t()
) :: check_opts()

validate_choose!(opts, op_name)

@spec validate_choose!(
  keyword(),
  String.t()
) :: choose_opts()

validate_click!(opts)

@spec validate_click!(keyword()) :: click_opts()

validate_fill_in!(opts)

@spec validate_fill_in!(keyword()) :: fill_in_opts()

validate_path!(opts, op_name)

@spec validate_path!(
  keyword(),
  String.t()
) :: path_opts()

validate_plug_session_options!(session_options, op_name)

@spec validate_plug_session_options!(
  keyword(),
  String.t()
) :: keyword()

validate_return_result!(opts, op_name)

@spec validate_return_result!(
  keyword(),
  String.t()
) :: return_result_opts()

validate_screenshot!(opts)

@spec validate_screenshot!(keyword()) :: screenshot_opts()

validate_select!(opts)

@spec validate_select!(keyword()) :: select_opts()

validate_session_browser!(opts)

@spec validate_session_browser!(keyword()) :: session_browser_opts()

validate_session_common!(opts)

@spec validate_session_common!(keyword()) :: session_common_opts()

validate_submit!(opts)

@spec validate_submit!(keyword()) :: submit_opts()

validate_upload!(opts)

@spec validate_upload!(keyword()) :: upload_opts()