Skip to content

Commit 8d1bc03

Browse files
fix: fixes for flaky table, multiselect, dropdown (#417)
This PR provides exception handling for multiselect and dropdown to get rid of flaky test cases. Additionaly wait_to_be_clickable added in table module.
1 parent e3abb30 commit 8d1bc03

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

pytest_splunk_addon_ui_smartx/components/controls/multi_select.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,19 @@ def select(self, value):
100100
)
101101
for each in self.get_elements("values"):
102102
if each.text.strip().lower() == value.lower():
103-
each.click()
103+
try:
104+
each.click()
105+
except ElementClickInterceptedException:
106+
self.elements.update(
107+
{
108+
value.lower(): Selector(
109+
select=popover_id
110+
+ f' [data-test="option"][data-test-value="{value.lower()}"]'
111+
)
112+
}
113+
)
114+
self.hover_over_element(f"{value.lower()}")
115+
each.click()
104116
self.wait_for("input")
105117
return True
106118
else:

pytest_splunk_addon_ui_smartx/components/dropdown.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import time
1818
from .base_component import BaseComponent, Selector
19+
from selenium.common.exceptions import ElementClickInterceptedException
1920

2021

2122
class Dropdown(BaseComponent):
@@ -106,7 +107,6 @@ def select_nested(self, values: list):
106107
"""
107108
if not isinstance(values, list):
108109
raise ValueError("{} has to be of type list".format(values))
109-
110110
self.wait_to_be_clickable("root")
111111
self.root.click()
112112
popoverid = "#" + self.root.get_attribute("data-test-popover-id")
@@ -119,13 +119,19 @@ def select_nested(self, values: list):
119119
for each in self.get_elements("dropdown_options"):
120120
if each.text.strip().lower() == value.lower():
121121
found = True
122-
each.click()
122+
try:
123+
each.click()
124+
except ElementClickInterceptedException:
125+
self.hover_over_element("root") # avoid tooltip interception
126+
each.click()
123127
time.sleep(
124128
1
125129
) # sleep here prevents broken animation resulting in unclicable button
126130
break
127131
if not found:
128-
raise ValueError("{} not found in select list".format(value))
132+
raise ValueError(
133+
f"{value} not found in select list. Values found {[_ for _.text.strip().lower in self.get_elements('values')]}"
134+
)
129135
return True
130136

131137
def select_input_type(self, value, open_dropdown=True):

pytest_splunk_addon_ui_smartx/components/table.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ def delete_row(self, name, cancel=False, close=False, prompt_msg=False):
363363
self.wait_for_text("delete_prompt")
364364
return self.get_clear_text(self.delete_prompt)
365365
else:
366+
self.wait_to_be_clickable("delete_btn")
366367
self.delete_btn.click()
367368
self.wait_until("waitspinner")
368369

0 commit comments

Comments
 (0)