arsenic.session¶
-
class
arsenic.session.Element¶ A web element. You should not create instances of this class yourself, instead use
Session.get_element()orSession.get_elements().-
get_text()¶ Coroutine to get the text of this element.
Return type: str
-
send_keys(keys)¶ Coroutine to send a sequence of keys to this element. Useful for text inputs.
Parameters: keys (str) – The keys to send. Use arsenic.keysfor special keys.
-
send_file(path): Coroutine to send a file to this element. Useful for file inputs.
Parameters: path (pathlib.Path) – The local path to the file.
-
clear()¶ Coroutine to clear this element. Useful for form inputs.
-
click()¶ Coroutine to click on this element.
-
is_displayed()¶ Coroutine to check if this element is displayed or not.
Return type: bool
-
is_enabled()¶ Coroutine to check if this element is enabled.
Return type: bool
-
get_attribute(name)¶ Coroutine which returns the value of a given attribute of this element.
Parameters: name (str) – Name of the attribute to get. Return type: str
-
select_by_value(value)¶ Coroutine to select an option by value. This is useful if this element is a select input.
Parameters: value (str) – Value of the option to select.
-
get_rect()¶ Coroutine to get the location and size of the element.
Return type: arsenic.utils.Rect
-
-
class
arsenic.session.Session¶ - A webdriver session. You should not create instances of this class yourself, instead use
arsenic.get_session()orarsenic.start_session().-
request(url, method='GET', data=UNSET): Coroutine to perform a direct webdriver request.
Parameters: - url (str) – URL to call.
- method (str) – method to use
- Any] (Dict[str,) – data to send
-
get(url): Coroutine to navigate to a given url.
param str url: URL to navigate to. -
get_url()¶ Coroutine to get the current URL.
Return type: str
-
get_page_source()¶ Coroutine to get the source of the current page.
Return type: str
-
get_element(selector)¶ Coroutine to get an element via CSS selector.
Parameters: selector (str) – CSS selector of the element. Return type: Element
-
get_elements(selector)¶ Coroutine to get a list of elements via CSS selector.
Parameters: selector (str) – CSS selector of the elements. Return type: List of Elementinstances.
-
wait_for_element(timeout, selector)¶ Coroutine like
get_element(), but waits up totimeoutseconds for the element to appear.Parameters: - timeout (int) – Timeout in seconds.
- selector (str) – CSS selector.
Return type:
-
wait_for_element_gone(timeout, selector)¶ Coroutine that waits up to
timeoutseconds for the element for the given CSS selector to no longer be available.Parameters: - timeout (int) – Timeout in seconds.
- selector (str) – CSS Selector.
Return type: None
Coroutine to set a cookie.
Parameters: - name (str) – Name of the cookie.
- value (str) – Value of the cookie.
- path (str) – Optional, keyword-only path of the cookie.
- domain (str) – Optional, keyword-only domain of the cookie.
- secure (bool) – Optional, keyword-only secure flag of the cookie.
- expiry (int) – Optional, keyword-only expiration of the cookie.
Return type: None
Coroutine to get the value of a cookie.
Parameters: name (str) – Name of the cookie. Return type: str
Coroutine to get all cookies.
Return type: dict
Coroutine to delete a specific cookie.
Parameters: name (str) – Name of the cookie to delete.
Coroutine to delete all cookies.
-
execute_script(script, *args)¶ Coroutine which executes a javascript script with the given arguments.
Parameters: - script (str) – Javascript script source to execute.
- args – Arguments to pass to the script. Must be JSON serializable.
-
set_window_size(width, height, handle='current')¶ Coroutine to set the size of a given window.
Parameters: - width (int) – Width in pixels.
- height (int) – Height in pixels.
- handle (str) – ID of the window.
-
get_window_size(handle='current')¶ Coroutine to get the size of a given window.
Parameters: handle (str) – ID of the window. Return type: Tuple[int, int]
-
get_window_handle()¶ Coroutine to get the handle of the current window
Return type: str
-
switch_to_window(handle)¶ Coroutine to set the handle of the current window
Parameters: handle (str) – ID of the window. Return type: str
-
get_window_handles()¶ Coroutine to get the handles of all windows
Return type: List[str]
-
get_alert_text()¶ Coroutine to return the text of an alert message.
Return type: str
-
send_alert_text(value)¶ Coroutine to send text to an alert message.
Parameters: value (str) – Value to send.
-
dismiss_alert()¶ Coroutine to dismiss an active alert.
-
accept_alert()¶ Coroutine to accept an active alert.
-
perform_actions(actions)¶ Coroutine to perform a series of actions. Use
arsenic.actions.chain()to build the actions object.
-
get_screenshot()¶ Coroutine to take a screenshot of the top-level browsing context’s viewport.
Return type: io.BytesIO
-
close()¶ Coroutine to close this session.
-
-