webdriver_test_tools.pageobject.modal module¶
-
class
webdriver_test_tools.pageobject.modal.
ModalObject
(driver)[source]¶ Bases:
webdriver_test_tools.pageobject.yaml.YAMLParsingPageObject
Page object prototype for modals
Subclasses should set the following attributes:
- Variables
ModalObject.YAML_FILE – Path to a YAML file representing the modal object. This file is parsed during initialization using
parse_yaml()
and is used to determineMODAL_LOCATOR
andCLOSE_LOCATOR
ModalObject.MODAL_BODY_CLASS – (Optional) Page object for the contents of the modal body. If set to a subclass of
BasePage
,get_modal_body()
will return an instance of this object.
The following attributes are determined based on the contents of
YAML_FILE
(or should be set in subclasses ifYAML_FILE
isNone
):- Variables
ModalObject.MODAL_LOCATOR – Locator for the modal element. Override in subclasses
ModalObject.CLOSE_LOCATOR – Locator for the close button. Override in subclasses
-
MODAL_LOCATOR
= None¶
-
CLOSE_LOCATOR
= None¶
-
MODAL_BODY_CLASS
= None¶
-
parse_yaml
(file_path)[source]¶ Parse a YAML representation of the modal object and set attributes accordingly
See YAML ModalObjects doc for details on syntax.
- Parameters
file_path – Full path to the YAML file
-
is_displayed
()[source]¶ Check if the modal is displayed
This method checks if the element located by
MODAL_LOCATOR
exists and is visible. This should be sufficient for many common implementations of modals, but can be overridden if this isn’t a reliable detection method for an implementation- Returns
True if the modal is displayed, False otherwise
Click the modal close button
-
get_modal_body
()[source]¶ If
self.MODAL_BODY_CLASS
is set to a subclass ofBasePage
, returns an instance of that object. Otherwise, returns None