Skip to content

Commit 6057be2

Browse files
ci: updating component
1 parent 4fd734d commit 6057be2

File tree

2 files changed

+33
-41
lines changed

2 files changed

+33
-41
lines changed

pytest_splunk_addon_ui_smartx/components/controls/checkboxgroup.py

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from ..base_component import Selector
1919
from .base_control import BaseControl
20-
from .button import Button
2120
from .checkbox import Checkbox
2221
from .textbox import TextBox
2322

@@ -65,34 +64,19 @@ def is_group_expanded(self, group_name: str) -> bool:
6564
== "true"
6665
)
6766

68-
def select_checkbox_and_set_value(
69-
self, checkbox_name: str, checkbox_value: str
70-
) -> None:
71-
"""
72-
Selects a checkbox and sets a value for the checkbox.
73-
74-
Args:
75-
checkbox_name (str): The name of the checkbox to select.
76-
checkbox_value (str): The value to set for the checkbox.
77-
"""
78-
Checkbox(
67+
def get_checkbox(self, checkbox_name: str) -> Checkbox:
68+
return Checkbox(
7969
self.browser,
8070
Selector(
8171
by=By.XPATH,
8272
select=self.elements.get("container").select
8373
+ f"//div[@data-test-field='{checkbox_name}']/parent::div",
8474
),
85-
).check()
86-
TextBox(
87-
self.browser,
88-
Selector(
89-
by=By.XPATH,
90-
select=self.elements.get("container").select
91-
+ f"//div[@data-test-field='{checkbox_name}' and @data-test='number']",
92-
),
93-
).set_value(checkbox_value)
75+
)
9476

95-
def select(self, group_name: str, checkbox_name: str, checkbox_value: str) -> None:
77+
def select_checkbox_and_set_value(
78+
self, group_name: str, checkbox_name: str, checkbox_value: str = None
79+
) -> None:
9680
"""
9781
Expands a group and selects a checkbox, then sets the specified value.
9882
@@ -102,9 +86,9 @@ def select(self, group_name: str, checkbox_name: str, checkbox_value: str) -> No
10286
checkbox_value (str): The value to set for the checkbox.
10387
"""
10488
self.expand_group(group_name)
105-
self.select_checkbox_and_set_value(
106-
checkbox_name=checkbox_name, checkbox_value=checkbox_value
107-
)
89+
self.get_checkbox(checkbox_name).check()
90+
if checkbox_value:
91+
self.get_textbox(checkbox_name).set_value(checkbox_value)
10892

10993
def deselect(self, group_name: str, checkbox_name: str) -> None:
11094
"""
@@ -115,18 +99,21 @@ def deselect(self, group_name: str, checkbox_name: str) -> None:
11599
checkbox_name (str): The name of the checkbox to deselect.
116100
"""
117101
self.expand_group(group_name)
118-
Checkbox(
102+
self.get_checkbox(checkbox_name).uncheck()
103+
104+
def get_textbox(self, checkbox_name: str) -> TextBox:
105+
return TextBox(
119106
self.browser,
120107
Selector(
121108
by=By.XPATH,
122109
select=self.elements.get("container").select
123-
+ f"//div[@data-test-field='{checkbox_name}']/parent::div",
110+
+ f"//div[@data-test-field='{checkbox_name}' and @data-test='number']",
124111
),
125-
).uncheck()
112+
)
126113

127-
def get_checkbox_value(self, group_name: str, checkbox_name: str) -> str:
114+
def get_checkbox_text_value(self, group_name: str, checkbox_name: str) -> str:
128115
"""
129-
Expands a group and retrieves the value of the specified checkbox.
116+
Expands a group and retrieves the text value of the specified checkbox.
130117
131118
Args:
132119
group_name (str): The name of the group to expand.
@@ -136,14 +123,7 @@ def get_checkbox_value(self, group_name: str, checkbox_name: str) -> str:
136123
str: The value of the checkbox.
137124
"""
138125
self.expand_group(group_name)
139-
return TextBox(
140-
self.browser,
141-
Selector(
142-
by=By.XPATH,
143-
select=self.elements.get("container").select
144-
+ f"//div[@data-test-field='{checkbox_name}' and @data-test='number']",
145-
),
146-
).get_value()
126+
return self.get_textbox(checkbox_name).get_value()
147127

148128
def expand_group(self, group_name: str) -> None:
149129
"""

tests/ui/test_splunk_ta_example_addon_input_2.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,12 @@ def test_example_input_two_add_backend_validation(
531531
input_page.entity2.example_multiple_select.select("Option Two")
532532
input_page.entity2.index.select("main")
533533
input_page.entity2.interval.set_value("90")
534-
input_page.entity2.checkboxgroup.select("EC2", "ec2_instances", "100")
535-
input_page.entity2.checkboxgroup.select("ELB", "classic_load_balancers", "100")
534+
input_page.entity2.checkboxgroup.select_checkbox_and_set_value(
535+
"EC2", "ec2_instances", "100"
536+
)
537+
input_page.entity2.checkboxgroup.select_checkbox_and_set_value(
538+
"ELB", "classic_load_balancers", "100"
539+
)
536540
input_page.entity2.example_account.select("test_input")
537541
input_page.entity2.query_start_date.set_value("2020-12-11T20:00:32.000z")
538542
self.assert_util(input_page.entity2.save, True)
@@ -616,7 +620,15 @@ def test_example_input_two_edit_backend_validation(
616620
input_page.entity2.query_start_date.set_value("2020-20-20T20:20:20.000z")
617621
input_page.entity2.checkboxgroup.deselect("EC2", "ec2_instances")
618622
input_page.entity2.checkboxgroup.deselect("ELB", "classic_load_balancers")
619-
input_page.entity2.checkboxgroup.select("VPC", "vpcs", "1000")
623+
self.assert_util(
624+
input_page.entity2.checkboxgroup.get_textbox(
625+
"ELB", "classic_load_balancers"
626+
).is_editable(),
627+
False,
628+
)
629+
input_page.entity2.checkboxgroup.select_checkbox_and_set_value(
630+
"VPC", "vpcs", "1000"
631+
)
620632
self.assert_util(input_page.entity2.save, True)
621633
input_page.table.wait_for_rows_to_appear(1)
622634
value_to_test = {

0 commit comments

Comments
 (0)