API Documentation¶
WebDriver Connector¶
- class genie.webdriver.connectors.WebDriverConnector(*args, **kwargs)[source]¶
Bases:
pyats.connections.bases.BaseConnection
instantiate a single connection instance.
- configure(*args, **kwargs)[source]¶
placeholder API to be implemented by the subclass: sends one or more multiline configurations to the device via this connection and expect some form of return. This api should block until expected output is received, and should be prompt-aware in CLI implementations.
Note
implementation shall use the @BaseConnection.lock decorator to add lock/unlock multiprocessing capability.
- connect()[source]¶
placeholder API to be implemented by the subclass: creates/opens the connection to given device.
- property connected¶
returns True/False for whether this pipeline instance is up
- Type
placeholder property to be implemented by the subclass
- disconnect()[source]¶
placeholder API to be implemented by the subclass: closing/disconnects the connection to given device.
- property execute¶
sends a command to the device via this connection and expect some form of return. This api should block until expected output is received - and should be prompt-aware in CLI implementations.
Note
implementation shall use the @BaseConnection.lock decorator to add lock/unlock multiprocessing capability.
- Type
placeholder API to be implemented by the subclass
Page Elements¶
- class genie.webdriver.element.PageElement(locator=None, **kwargs)[source]¶
Bases:
object
Descriptor class to allow enhancement to WebPage classes by adding additional functionality without explicitly writing a lot of code
Interactions¶
- class genie.webdriver.interact.Interactions(driver, timeout)[source]¶
Bases:
object
- click_button_with_text(text)[source]¶
click on any button that matches the text
- Arguments
text (str): string matching text value
- click_link_with_text(text)[source]¶
click on any link with provided link text
- Arguments
text (str): string matching link text
- click_on_svg_element(css)[source]¶
click on an svg element
- Arguments
css (str): css value describing the svg location
- double_click(element=None, locator=None, **kwargs)[source]¶
double click on provided element or locator matching that element
- Arguments
element (object): selenium element to double click on locator (tuple): selenium locator tuple or kwargs describing the
location
- drag_and_drop(source, dest)[source]¶
Drags and drops element from source to destination.
- Arguments
source (tuple): locator that needs to be dragged dest (tuple): locator that needs to be dropped to
- drag_and_drop_element(source, dest)[source]¶
Drags and drops element from source to destination.
- Arguments
source (element): name of the element that needs to be dragged dest (element): name of the element that needs to be dropped to
- hover(element=None, x_offset=0, y_offset=0, locator=None, **kwargs)[source]¶
hover over a particular element
- Arguments
element (object): selenium element to double click on locator (tuple): selenium locator tuple or kwargs describing the
location
x_offset/y_offset (int): pixel offets from uppler left top corner.
- jquery_click(css)[source]¶
perform a jquery click on provided css element
- Arguments
css (str): css value describing the svg location
- scroll_into_view(element=None, locator=None, **kwargs)[source]¶
scroll provided element/location into view
- Arguments
element (object): selenium element to double click on locator (tuple): selenium locator tuple or kwargs describing the
location
- select_from_drop_down(option, locator=None, **kwargs)[source]¶
select text from drop down list
- Arguments
option (text): text to match for selection locator (tuple): selenium locator tuple or kwargs describing the
location
- send_return(locator=None, **kwargs)[source]¶
send enter key to located element
- Arguments
- locator (tuple): selenium locator tuple or kwargs describing the
location
- send_tab(locator=None, **kwargs)[source]¶
send tab key to located element
- Arguments
- locator (tuple): selenium locator tuple or kwargs describing the
location
Waits¶
- class genie.webdriver.wait.Wait(driver, timeout)[source]¶
Bases:
object
Wait object, intended to be used as an attribute under page, for shortcut use of selenium wait/ec apis without explicitly having to import them and/or refer to their syntax.
Example
# typical selenium code from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10) element = wait.until(EC.element_to_be_clickable((By.ID, ‘someid’)))
# using this wait class page = WebPage(driver) page.wait.until.element_to_be_clickable(id = ‘someid’, timeout = 10)
- class genie.webdriver.wait.WaitUntil(driver, timeout)[source]¶
Bases:
object
Class to allow users to perform a wait-until
- alert_is_present(**kwargs)[source]¶
Expect an alert to be present.
- Arguments
timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- element_located_selection_state_to_be(*, state, locator=None, **kwargs)[source]¶
An expectation to locate an element and check if the selection state specified is in that state.
- This API supports kwargs style location-by shorthand. Eg:
- WaitUntil.element_located_selection_state_to_be((By.ID,
‘loginForm’), ..)
- is the same as
- WaitUntil.element_located_selection_state_to_be(id = ‘loginForm’,
…)
- Arguments
locator (tuple): location describing the location by state (bool): true or false timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- element_located_to_be_selected(locator=None, **kwargs)[source]¶
An expectation for the element to be located is selected. locator is a tuple of (by, path)
- This API supports kwargs style location-by shorthand. Eg:
WaitUntil.element_located_to_be_selected((By.ID, ‘loginForm’), ..)
- is the same as
WaitUntil.element_located_to_be_selected(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- element_selection_state_to_be(element, state, **kwargs)[source]¶
An expectation for checking if the given element is selected. element is WebElement object
- Arguments
element (obj): element to check for state (bool): true or false timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- element_to_be_clickable(locator=None, **kwargs)[source]¶
An Expectation for checking an element is visible and enabled such that you can click it
- This API supports kwargs style location-by shorthand. Eg:
WaitUntil.element_to_be_clickable((By.ID, ‘loginForm’), ..)
- is the same as
WaitUntil.element_to_be_clickable(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- element_to_be_selected(element, **kwargs)[source]¶
An expectation for checking the selection is selected. element is WebElement object
- Arguments
element (obj): element to check for timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- frame_to_be_available_and_switch_to_it(locator=None, **kwargs)[source]¶
An expectation for checking whether the given frame is available to switch to. If the frame is available it switches the given driver to the specified frame.
- This API supports kwargs style location-by shorthand. Eg:
- WaitUntil.frame_to_be_available_and_switch_to_it((By.ID,
‘loginForm’), ..)
- is the same as
- WaitUntil.frame_to_be_available_and_switch_to_it(id = ‘loginForm’,
…)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- invisibility_of_element_located(locator=None, **kwargs)[source]¶
An Expectation for checking that an element is either invisible or not present on the DOM.
- This API supports kwargs style location-by shorthand. Eg:
- WaitUntil.invisibility_of_element_located((By.ID,
‘loginForm’), ..)
- is the same as
- WaitUntil.invisibility_of_element_located(id = ‘loginForm’,
…)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- new_window_is_opened(current_handles, **kwargs)[source]¶
An expectation that a new window will be opened and have the number of windows handles increase
- Arguments
current_handles (obj): current handle object timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- number_of_windows_to_be(num_windows, **kwargs)[source]¶
An expectation for the number of windows to be a certain value.
- Arguments
num_windows (int): number of windows timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- presence_of_all_elements_located(locator=None, **kwargs)[source]¶
An expectation for checking that there is at least one element present on a web page. locator is used to find the element returns the list of WebElements once they are located
- This API supports kwargs style location-by shorthand. Eg:
WaitUntil.presence_of_all_elements_located((By.ID, ‘loginForm’), ..)
- is the same as
WaitUntil.presence_of_all_elements_located(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- presence_of_element_located(locator=None, **kwargs)[source]¶
An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible. locator - used to find the element returns the WebElement once it is located
- This API supports kwargs style location-by shorthand. Eg:
WaitUntil.presence_of_element_located((By.ID, ‘loginForm’), …)
- is the same as
WaitUntil.presence_of_element_located(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- staleness_of(element, **kwargs)[source]¶
Wait until an element is no longer attached to the DOM. element is the element to wait for. returns False if the element is still attached to the DOM, true otherwise.
- Arguments
element (obj): element to check for timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- text_to_be_present_in_element(*, text, locator=None, **kwargs)[source]¶
An expectation for checking if the given text is present in the specified element. locator, text
- This API supports kwargs style location-by shorthand. Eg:
WaitUntil.text_to_be_present_in_element((By.ID, ‘loginForm’), ..)
- is the same as
WaitUntil.text_to_be_present_in_element(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by text (str): text to search for in element timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- text_to_be_present_in_element_value(*, text, locator=None, **kwargs)[source]¶
An expectation for checking if the given text is present in the element’s locator, text
- This API supports kwargs style location-by shorthand. Eg:
- WaitUntil.text_to_be_present_in_element_value((By.ID,
‘loginForm’), ..)
- is the same as
WaitUntil.text_to_be_present_in_element_value(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by text (str): text to search for in element timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- title_contains(title, **kwargs)[source]¶
An expectation for checking that the title contains a case-sensitive substring. title is the fragment of title expected returns True when the title matches, False otherwise
- Arguments
title (str): title to check for timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- title_is(title, **kwargs)[source]¶
An expectation for checking the title of a page. title is the expected title, which must be an exact match returns True if the title matches, false otherwise.
- Arguments
title (str): title to check for timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- visibility_of(element, **kwargs)[source]¶
An expectation for checking that an element, known to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. element is the WebElement returns the (same) WebElement once it is visible
- Arguments
element (obj): element to check for timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- visibility_of_any_elements_located(locator=None, **kwargs)[source]¶
An expectation for checking that there is at least one element visible on a web page. locator is used to find the element returns the list of WebElements once they are located
- This API supports kwargs style location-by shorthand. Eg:
- WaitUntil.visibility_of_any_elements_located((By.ID, ‘loginForm’),
..)
- is the same as
WaitUntil.visibility_of_any_elements_located(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- visibility_of_element_located(locator=None, **kwargs)[source]¶
An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0. locator - used to find the element returns the WebElement once it is located and visible
- This API supports kwargs style location-by shorthand. Eg:
WaitUntil.visibility_of_element_located((By.ID, ‘loginForm’), …)
- is the same as
WaitUntil.visibility_of_element_located(id = ‘loginForm’, …)
- Arguments
locator (tuple): location describing the location by timeout (int): seconds to wait for message (str): message to display if timed out kwargs (dict): any other argument for WebDriverWait() api
- class genie.webdriver.wait.WaitUntilNot(driver, timeout)[source]¶
Bases:
genie.webdriver.wait.WaitUntil
Class to allow users to perform a wait-until-not