|
| 1 | +from time import sleep |
1 | 2 | from typing import Union
|
2 | 3 |
|
3 | 4 | from selenium.webdriver.remote.webelement import WebElement
|
@@ -26,29 +27,34 @@ def verify_element_displayed(self, reference: Union[str, tuple, WebElement]):
|
26 | 27 | @BasePage.context_chrome
|
27 | 28 | def ensure_autofill_dropdown_not_visible(self):
|
28 | 29 | """
|
29 |
| - Verifies that the autofill dropdown does NOT appear |
30 |
| - checks if the parent pop up component have children elements before explicit wait. |
| 30 | + Verifies that the autofill dropdown does not appear |
| 31 | + checks if the parent pop up component has hidden attribute. |
31 | 32 | """
|
32 | 33 | self.element_exists("pop-up-component")
|
33 |
| - popup_component = self.get_element("pop-up-component") |
34 |
| - if popup_component and len(popup_component.get_attribute("innerHTML")) > 1: |
35 |
| - self.element_not_visible("select-form-option") |
| 34 | + self.expect_element_attribute_contains("pop-up-component", "hidden", "true") |
36 | 35 | return self
|
37 | 36 |
|
38 | 37 | @BasePage.context_chrome
|
39 |
| - def ensure_autofill_dropdown_visible(self, field_element: WebElement = None): |
| 38 | + def ensure_autofill_dropdown_visible(self): |
40 | 39 | """
|
41 | 40 | Verifies that the autofill dropdown appears
|
42 |
| - checks if the parent pop up component have children elements before explicit wait. |
43 |
| -
|
44 |
| - Arguments: |
45 |
| - field_element: if field element is given. |
46 |
| - check whether it is a select element. pass the check if it is. |
| 41 | + checks if the parent pop up component has hidden attribute. |
47 | 42 | """
|
48 |
| - self.element_exists("pop-up-component") |
49 |
| - popup_component = self.get_element("pop-up-component") |
50 |
| - if popup_component: |
51 |
| - self.element_visible("select-form-option") |
| 43 | + self.expect( |
| 44 | + lambda _: len( |
| 45 | + self.get_element("pop-up-component").get_attribute("innerHTML") |
| 46 | + ) |
| 47 | + > 1 |
| 48 | + ) |
| 49 | + assert self.get_element("pop-up-component").get_attribute("hidden") is None, ( |
| 50 | + "Pop up autofill panel hidden." |
| 51 | + ) |
| 52 | + return self |
| 53 | + |
| 54 | + @BasePage.context_chrome |
| 55 | + def hover_over_autofill_panel(self): |
| 56 | + self.element_visible("select-form-option") |
| 57 | + self.hover("select-form-option") |
52 | 58 | return self
|
53 | 59 |
|
54 | 60 | # Interaction with popup elements
|
@@ -110,6 +116,14 @@ def select_nth_element(self, index: int):
|
110 | 116 | )
|
111 | 117 | self.get_element("select-form-option-by-index", labels=[str(index)]).click()
|
112 | 118 |
|
| 119 | + @BasePage.context_chrome |
| 120 | + def select_autofill_panel(self): |
| 121 | + """ |
| 122 | + Select the first autofill panel in the autocomplete list. |
| 123 | + """ |
| 124 | + self.get_element("select-form-option-autofill").click() |
| 125 | + return self |
| 126 | + |
113 | 127 | @BasePage.context_chrome
|
114 | 128 | def get_primary_value(self, element: WebElement) -> str:
|
115 | 129 | """
|
|
0 commit comments