Skip to content

Commit 7add7c5

Browse files
fix: dynamic handle input status toggle [ADDON-71796] (#432)
As requested in https://splunk.atlassian.net/browse/ADDON-71796. input_status_toggle() is no longer based on literal value of `data-test`, instead it's based on actual status of the button `data-selected` attribute. Tests in ucc: https://github.com/splunk/addonfactory-ucc-generator/runs/27207848699 Without fix: https://github.com/splunk/addonfactory-ucc-generator/runs/26432377281
1 parent bf89719 commit 7add7c5

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

pytest_splunk_addon_ui_smartx/components/input_table.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,32 +62,25 @@ def input_status_toggle(self, name, enable):
6262
:return: Bool whether or not enabling or disabling the field was successful, If the field was already in the state we wanted it in, then it will return an exception
6363
"""
6464
_row = self._get_row(name)
65-
input_status = _row.find_element(
66-
*list(self.elements["input_status"]._asdict().values())
67-
)
68-
status = (
69-
input_status.find_element_by_css_selector('[data-test="status"]')
70-
.text.strip()
71-
.lower()
72-
)
7365
status_button = _row.find_element(
7466
*list(self.elements["status_toggle"]._asdict().values())
7567
)
68+
input_enabled = (
69+
True
70+
if status_button.get_attribute("data-selected").lower().strip() == "true"
71+
else False
72+
)
7673
if enable:
77-
if status == "enabled":
78-
raise Exception(
79-
"The input is already {}".format(self.input_status.text.strip())
80-
)
81-
elif status == "disabled":
74+
if input_enabled:
75+
raise Exception("The input is already enabled")
76+
else:
8277
status_button.click()
8378
self.wait_until("switch_button_status")
8479
return True
8580
else:
86-
if status == "disabled":
87-
raise Exception(
88-
"The input is already {}".format(self.input_status.text.strip())
89-
)
90-
elif status == "enabled":
81+
if not input_enabled:
82+
raise Exception("The input is already disabled")
83+
else:
9184
status_button.click()
9285
self.wait_until("switch_button_status")
9386
return True

0 commit comments

Comments
 (0)