@@ -40,27 +40,27 @@ def __init__(self, browser, container) -> None:
4040 """
4141 super ().__init__ (browser , container )
4242
43- def is_group_expanded (self , group_name : str ) -> bool :
43+ def is_group_expanded (self , checkbox_group_name : str ) -> bool :
4444 """
4545 Checks if the specified group is expanded.
4646
4747 Args:
48- group_name (str): The name of the checkbox group to check.
48+ checkbox_group_name (str): The name of the checkbox group to check.
4949
5050 Returns:
5151 bool: True if the group is expanded, False otherwise.
5252 """
5353 self .elements .update (
5454 {
55- f"{ group_name } _button" : Selector (
55+ f"{ checkbox_group_name } _button" : Selector (
5656 by = By .XPATH ,
5757 select = self .elements .get ("container" ).select
58- + f'//span[text()="{ group_name } "]/ancestor::button' ,
58+ + f'//span[text()="{ checkbox_group_name } "]/ancestor::button' ,
5959 )
6060 }
6161 )
6262 return (
63- getattr (self , f"{ group_name } _button" ).get_attribute ("aria-expanded" )
63+ getattr (self , f"{ checkbox_group_name } _button" ).get_attribute ("aria-expanded" )
6464 == "true"
6565 )
6666
@@ -75,30 +75,30 @@ def get_checkbox(self, checkbox_name: str) -> Checkbox:
7575 )
7676
7777 def select_checkbox_and_set_value (
78- self , group_name : str , checkbox_name : str , checkbox_value : str = None
78+ self , checkbox_group_name : str , checkbox_name : str , checkbox_value : str = None
7979 ) -> None :
8080 """
8181 Expands a group and selects a checkbox, then sets the specified value.
8282
8383 Args:
84- group_name (str): The name of the group to expand.
84+ checkbox_group_name (str): The name of the group to expand.
8585 checkbox_name (str): The name of the checkbox to select.
8686 checkbox_value (str): The value to set for the checkbox.
8787 """
88- self .expand_group (group_name )
88+ self .expand_group (checkbox_group_name )
8989 self .get_checkbox (checkbox_name ).check ()
9090 if checkbox_value :
9191 self .get_textbox (checkbox_name ).set_value (checkbox_value )
9292
93- def deselect (self , group_name : str , checkbox_name : str ) -> None :
93+ def deselect (self , checkbox_group_name : str , checkbox_name : str ) -> None :
9494 """
9595 Expands a group and deselects the specified checkbox.
9696
9797 Args:
98- group_name (str): The name of the group to expand.
98+ checkbox_group_name (str): The name of the group to expand.
9999 checkbox_name (str): The name of the checkbox to deselect.
100100 """
101- self .expand_group (group_name )
101+ self .expand_group (checkbox_group_name )
102102 self .get_checkbox (checkbox_name ).uncheck ()
103103
104104 def get_textbox (self , checkbox_name : str ) -> TextBox :
@@ -111,27 +111,38 @@ def get_textbox(self, checkbox_name: str) -> TextBox:
111111 ),
112112 )
113113
114- def get_checkbox_text_value (self , group_name : str , checkbox_name : str ) -> str :
114+ def get_checkbox_text_value (self , checkbox_group_name : str , checkbox_name : str ) -> str :
115115 """
116116 Expands a group and retrieves the text value of the specified checkbox.
117117
118118 Args:
119- group_name (str): The name of the group to expand.
119+ checkbox_group_name (str): The name of the group to expand.
120120 checkbox_name (str): The name of the checkbox to retrieve the value from.
121121
122122 Returns:
123123 str: The value of the checkbox.
124124 """
125- self .expand_group (group_name )
125+ self .expand_group (checkbox_group_name )
126126 return self .get_textbox (checkbox_name ).get_value ()
127127
128- def expand_group (self , group_name : str ) -> None :
128+ def expand_group (self , checkbox_group_name : str ) -> None :
129129 """
130130 Expands the specified group if it is not already expanded.
131131
132132 Args:
133- group_name (str): The name of the group to expand.
133+ checkbox_group_name (str): The name of the group to expand.
134134 """
135- is_expanded = self .is_group_expanded (group_name )
135+ is_expanded = self .is_group_expanded (checkbox_group_name )
136136 if not is_expanded :
137- getattr (self , f"{ group_name } _button" ).click ()
137+ getattr (self , f"{ checkbox_group_name } _button" ).click ()
138+
139+ def collapse_group (self , checkbox_group_name : str ) -> None :
140+ """
141+ collapse the specified group if it is not already expanded.
142+
143+ Args:
144+ checkbox_group_name (str): The name of the group to expand.
145+ """
146+ is_expanded = self .is_group_expanded (checkbox_group_name )
147+ if is_expanded :
148+ getattr (self , f"{ checkbox_group_name } _button" ).click ()
0 commit comments