Hound.Helpers.Element
Functions to work with an element
Summary
Functions
Gets an element’s attribute value
Clears textarea or input field’s value
Click on an element. You can also use this to click on checkboxes and radio buttons
Gets an element’s computed CSS property
Checks if an element is currently displayed
Checks if an input field is enabled
Gets an element’s location on page. It returns the location as a tuple of the form {x, y}
Gets an element’s size in pixels. It returns the size as a tuple of the form {width, height}
Sets a field’s value. The difference with input_info_field
is that, the field is cleared before entering the new value
Enters value into field
Checks if two element IDs refer to the same DOM element
Checks if a radio input group or checkbox has any value selected
Sends a submit event to any field or form element
Gets an element’s tag name
Gets visible text of element. Requires the element ID
Types
element_selector :: {atom, String.t}
Functions
Gets an element’s attribute value.
element_id = find_element(:name, "example")
attribute_value(element_id, "data-greeting")
You can also pass the selector as a tuple, for the first argument
attribute_value({:name, "example"}, "data-greeting")
Specs
clear_field(element) :: :ok
Clears textarea or input field’s value
element_id = find_element(:class, "example")
clear_field(element_id)
You can also directly pass the selector as a tuple.
clear_field({:class, "example"})
Specs
click(element) :: :ok
Click on an element. You can also use this to click on checkboxes and radio buttons.
element_id = find_element(:id, ".example")
click(element_id)
You can also directly pass the selector as a tuple.
click({:id, "example"})
Gets an element’s computed CSS property.
element_id = find_element(:name, "example")
css_property(element_id, "display")
You can also pass the selector as a tuple, for the first argument
css_property({:name, "example"}, "display")
Specs
element_displayed?(element) :: true | false
Checks if an element is currently displayed.
element_id = find_element(:name, "example")
element_displayed?(element_id)
You can also pass the selector as a tuple.
element_displayed?({:name, "example"})
Specs
element_enabled?(element) :: true | false
Checks if an input field is enabled.
element_id = find_element(:name, "example")
element_enabled?(element_id)
You can also pass the selector as a tuple.
element_enabled?({:name, "example"})
Specs
element_location(element) :: tuple
Gets an element’s location on page. It returns the location as a tuple of the form {x, y}.
element_id = find_element(:name, "example")
element_location(element_id)
You can also pass the selector as a tuple.
element_location({:name, "example"})
Specs
element_size(element) :: tuple
Gets an element’s size in pixels. It returns the size as a tuple of the form {width, height}.
element_id = find_element(:name, "example")
element_location(element_id)
You can also pass the selector as a tuple.
element_location({:name, "example"})
Sets a field’s value. The difference with input_info_field
is that, the field is cleared before entering the new value.
element_id = find_element(:id, "example")
fill_field(element_id, "John Doe")
You can also pass the selector as a tuple, for the first argument.
fill_field({:id, "example"}, "John Doe")
Enters value into field.
It does not clear the field before entering the new value. Anything passed is added to the value already present.
element_id = find_element(:id, "example")
input_into_field(element_id, "John Doe")
You can also pass the selector as a tuple, for the first argument.
input_into_field({:id, "example"}, "John Doe")
Checks if two element IDs refer to the same DOM element.
element_id1 = find_element(:name, "username")
element_id2 = find_element(:id, "user_name")
same_element?(element_id1, element_id2)
Specs
selected?(element) :: true | false
Checks if a radio input group or checkbox has any value selected.
element_id = find_element(:name, "example")
selected?(element_id)
You can also pass the selector as a tuple.
selected?({:name, "example"})
Specs
submit_element(element) :: :ok
Sends a submit event to any field or form element.
element_id = find_element(:name, "username")
submit(element_id)
You can also directly pass the selector as a tuple.
submit({:name, "username"})
Gets an element’s tag name.
element_id = find_element(:class, "example")
tag_name(element_id)
You can also directly pass the selector as a tuple.
tag_name({:class, "example"})