base_component¶
ActionChains(browser)
¶
Bases: ActionChains
Purpose: It is a workaround by wrapping ActionChains class so that key_action.pause is not used in Safari browser.
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
36 37 38 39 |
|
BaseComponent(browser, container)
¶
Purpose: The base class for the component. A component is an UI component with which a user interacts with. The component class will have all the interaction method which can be done to the component.
Implementation: - The component will have set of locators. Locators can be of type (ID, CSS_Selector, classname, Name, etc. whichever supported by selenium) - Each method will interact with theses locators directly. - The component should have a container, so that it does not have multiple confusing instances in a same page. - In a container, there should be only one component of the same type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
browser |
The instance of the selenium webdriver |
required | |
container |
The container in which the component is located at. |
required |
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
55 56 57 58 59 60 61 62 63 |
|
__getattr__(key)
¶
Makes the web-elements to be accessible directly. - For example self.elements = {“textbox”: Selector(by=…, select=…), Access the element by doing self.textbox directly. - It also has implicit wait while finding the element. :param key: The key of the element mentioned in self.elements :returns: The webelement we are accessing
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
get_child_element(key)
¶
Get the web-element located inside the container. - It is more preferable to use get_child_element over get_element. - get_element should only be used if the element is out of the container for some reason. For example, in case of some pop-up.
Note: There is a wait in the method. :param key: The key of the element mentioned in self.elements :returns: The child element of the element searched by key
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
99 100 101 102 103 104 105 106 107 108 109 110 |
|
get_child_elements(key)
¶
Get the list of web-elements located inside the container. Returns empty list of no elements found. - It is more preferable to use get_child_elements over get_elements. - get_elements should only be used if the element is out of the container for some reason. For example, in case of some pop-up.
Note: There is a wait in the method. :param key: The key of the element mentioned in self.elements :returns: list The child elements of the element searched by key
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
get_clear_text(web_element)
¶
Gets the text of the web element :param web_element: The instance of the web element we are getting tect from. :returns: str the text of the web elements
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
65 66 67 68 69 70 71 |
|
get_element(key)
¶
Get the web-element.
Note: There is a wait in get_element. :param key: The key of the element mentioned in self.elements :returns: element The element we are looking for by key
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
73 74 75 76 77 78 79 80 81 82 |
|
get_elements(key)
¶
Get the list of web-elements.
Note: There is a wait in the method. :param key: The key of the element mentioned in self.elements :returns: list of elements we are searching for by key, or an empty list
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
get_tuple(key)
¶
get the locator of the element in a tuple form. :param key: The key of the element mentioned in self.elements :returns: Tuple of the locator
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
129 130 131 132 133 134 135 |
|
hover_over_element(key)
¶
Hover over an element, such as a tooltip, such that other items will appear :param key: The key of the element mentioned in self.elements
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
226 227 228 229 230 231 232 233 |
|
wait_for(key, msg=None, timeout=None)
¶
if key in element, Wait for an web element to be visible. Raises TimeoutException if the element not found. if key is a condition, wait for the condition to be true.
:param key: The key of the element mentioned in self.elements
:param msg: The error-msg which should be mentioned in the TimeoutException
:param timeout: The amount of time specified to wait for the wait function
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
wait_for_text(key, msg=None)
¶
if key in element, Wait for an text in web element to be visible. Raises TimeoutException if the text not element found. :param key: The key of the element mentioned in self.elements :param msg: The error-msg which should be mentioned in the TimeoutException
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
wait_to_be_clickable(key, msg=None)
¶
Wait for an web element to be invisible. Raises TimeoutException if the element does not dissapear. :param key: The key of the element mentioned in self.elements :param msg: The error-msg which should be mentioned in the TimeoutException
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
201 202 203 204 205 206 207 208 209 210 |
|
wait_to_display()
¶
Wait for the component container to be displayed
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
185 186 187 188 189 |
|
wait_until(key, msg=None)
¶
Wait for an web element to be invisible. Raises TimeoutException if the element does not dissapear. :param key: The key of the element mentioned in self.elements :param msg: The error-msg which should be mentioned in the TimeoutException
Source code in pytest_splunk_addon_ui_smartx/components/base_component.py
175 176 177 178 179 180 181 182 183 |
|