webdriver_test_tools.pageobject.form module

class webdriver_test_tools.pageobject.form.InputObject(driver, input_dict)[source]

Bases: webdriver_test_tools.pageobject.base.BasePage

Page object prototype for input elements

class Type[source]

Bases: object

Set of supported input types

CHECKBOX = 'checkbox'
EMAIL = 'email'
FILE = 'file'
NUMBER = 'number'
PASSWORD = 'password'
RADIO = 'radio'
SEARCH = 'search'
TEXT = 'text'
URL = 'url'
SELECT = 'select'
TEXTAREA = 'textarea'
SUPPORTS_OPTIONS = ['select', 'radio', 'checkbox']

Input types that support the ‘options’ key

SUPPORTS_MULTIPLE = ['select', 'checkbox']

Input types that support the ‘multiple’ key

find_input_element()[source]

Returns the WebElement object located by self.locator

Shorthand for self.find_element(self.locator)

Returns

WebElement object for the input

find_input_elements()[source]

Returns the list of WebElement objects located by self.locator. Used for input types that can have multiple elements corresponding to it (e.g. radios)

Shorthand for self.find_elements(self.locator)

Returns

List of WebElement objects for the inputs

set_value(value, **kwargs)[source]

Set the value of the input

Parameters

value

The value to set it to

  • For radio elements, this should be the value attribute of the radio to select.

  • For checkbox elements, this value should be a boolean (True=checked, False=unchecked).

  • For checkbox groups, this value should be a dictionary mapping checkbox input’s value attribute to the desired checked state (True = check, False = uncheck).

  • For single select elements, this value should be the value of the option to select.

  • For multiple select elements, this value should be a list of values of the options to select.

  • For file inputs, this value should be a filepath to the desired file.

  • For other input types (text, number, etc) this should be a string representation of the values to enter into it.

Additionally accepts keyword arguments based on the type of input this InputObject represents. See the above _set methods for type-specific optional arguments

get_value()[source]

Returns the current value of the input

class webdriver_test_tools.pageobject.form.FormObject(driver)[source]

Bases: webdriver_test_tools.pageobject.yaml.YAMLParsingPageObject

Page object prototype for forms

Subclasses should set the following attributes:

Variables

The following attributes are determined based on the contents of YAML_FILE (or should be set in subclasses if YAML_FILE is None):

Variables

The following attribute is set based on the ‘inputs’ key parsed from YAML_FILE (or parsed from INPUT_DICTS, which should be set in subclasses if YAML_FILE is None):

Variables

FormObject.inputs – A dictionary mapping input names to the corresponding InputObject instances. The keys correspond with the name keys in the YAML representation of the form (or the ‘name’ keys in INPUT_DICTS if YAML_FILE is None)

If YAML_FILE is None, subclasses must set the following attribute:

Variables

FormObject.INPUT_DICTS – List of input dictionaries. These are used to initialize the InputObject instances in inputs at runtime. These dictionaries use the same syntax as YAML inputs

SUBMIT_SUCCESS_CLASS = None
FORM_LOCATOR = None
SUBMIT_LOCATOR = None
INPUT_DICTS = []
inputs = {}
parse_yaml(file_path)[source]

Parse a YAML representation of the form object and set attributes accordingly

See YAML FormObjects doc for details on syntax.

Parameters

file_path – Full path to the YAML file

no_yaml_init()[source]

Initialize self.inputs using values in INPUT_DICTS

fill_inputs(input_map, strict=False)[source]

Fill form inputs

Parameters
  • input_map – Dictionary mapping input name key to the values to set them to. See InputObject.set_value() for value formats for different input types

  • strict – (Default = False) If True, throw an exception if a key in input_map is not a valid key in self.inputs. Otherwise throw a warning and continue

get_input_values(name_list=None)[source]

Get the current values of form inputs

Parameters

name_list – (Optional) List of input names to get values for. If unspecified, will get values for all inputs

Returns

Dictionary mapping names to the value of each input

submit_is_enabled()[source]

Short hand function for checking if the submit button is enabled. Useful for forms with JavaScript input validation

Returns

True if submit is enabled, False if it’s disabled

click_submit()[source]

Shorthand function for scrolling to the submit button and clicking it.

If self.SUBMIT_SUCCESS_CLASS is set to a subclass of BasePage, an instance of that object will be returned