Actions¶
Action functions cause the driver to complete an action, either on an element or the browser.
These functions operate on an element or browser, and don’t return.
check¶
-
check
()¶
Checks a checkbox. Always leaves the checkbox in a ‘selected’ state, no matter whether it was checked or unchecked when the action was performed.
- Returns
None
- Example
>>> browser.get_element(id="my_checkbox").check()
click¶
-
click
()¶
Clicks the element.
- Returns
None
- Examples
>>> browser.get_button(id="my-button").click() >>> browser.get_element(link_text="Python Package Index (PyPI)").click()
fill¶
-
fill
(string)¶
Fills an input field with a string of text or filepath. Clears any existing input from the field prior to filling.
- Parameters
- string
str
The text or filepath as a string.
- Returns
None
- Examples
>>> browser.get_element(id="my_input_field").fill("my_string") >>> browser.get_input(label="Attach file").fill("my_filepath")
quit¶
-
quit
()¶
Quits the browser. Operates on a browser, not an element.
- Returns
None
- Example
>>> browser.quit()
screenshot¶
-
screenshot
(filepath)¶
Takes a screenshot of either the full browser or an element, and saves it to a given filepath.
- Parameters
- filepath
str
The full filepath, as a string.
- Returns
None
- Examples
>>> browser.get_element(id="screenshot").screenshot("element.png") >>> browser.screenshot("page.png")
select¶
-
select
()¶
Selects a radio button, select option, or checkbox element. Always leaves the target element in a selected state, no matter whether it was already selected.
- Returns
None
- Examples
>>> browser.get_element(id="my_radio_button").select() >>> browser.get_element(id="selector_id").get_element(text="option_text").select() >>> browser.get_element(id="selector_id").get_element(value="option_value").select()