1717
1818from ..base_component import Selector
1919from .base_control import BaseControl
20- from .button import Button
2120from .checkbox import Checkbox
2221from .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 """
0 commit comments