@@ -130,7 +130,9 @@ def change_tab(browser: webdriver.Chrome, tab_index: int):
130
130
131
131
132
132
def approve_case (browser : webdriver .Chrome ):
133
- """Approve a case, even if blocked by a note."""
133
+ """Approve a case.
134
+ If any person on the case is blocking approval, approve each person individually.
135
+ """
134
136
change_tab (browser , 0 )
135
137
136
138
deadline_field = browser .find_element (By .ID , "ctl00_ContentPlaceHolder2_ptFanePerson_ncPersonTab_txtDeadline" )
@@ -142,20 +144,22 @@ def approve_case(browser: webdriver.Chrome):
142
144
browser .find_element (By .ID , "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnApproveYes" ).click ()
143
145
144
146
approve_persons_button = browser .find_element (By .ID , "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnGodkendAlle" )
145
- if not approve_persons_button .is_enabled ():
147
+ if approve_persons_button .is_enabled ():
148
+ approve_persons_button .click ()
149
+ else :
150
+ # Approve each person individually
151
+ person_count = len (browser .find_elements (By .XPATH , '//table[@id="ctl00_ContentPlaceHolder2_GridViewMovingPersons"]//tr' )) - 1
146
152
147
- person_table = browser .find_element (By .ID , "ctl00_ContentPlaceHolder2_GridViewMovingPersons" )
148
- rows = person_table .find_elements (By .TAG_NAME , "tr" )
149
- rows .pop (0 )
153
+ for i in range (person_count ):
154
+ browser .find_element (By .XPATH , f'//table[@id="ctl00_ContentPlaceHolder2_GridViewMovingPersons"]//tr[{ i + 2 } ]//td[2]' ).click ()
150
155
151
- for row in rows :
152
- row .find_element (By .XPATH , "td[2]" ).click ()
153
156
browser .find_element (By .ID , "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnGodkend" ).click ()
154
157
approve_button = browser .find_element (By .ID , "ctl00_ContentPlaceHolder2_ptFanePerson_stcPersonTab1_btnApproveYes" )
155
158
if approve_button .is_displayed ():
156
159
approve_button .click ()
157
- else :
158
- approve_persons_button .click ()
160
+
161
+ # Go back to the case
162
+ browser .find_element (By .XPATH , '//table[@id="ctl00_ContentPlaceHolder2_GridViewMovingPersons"]//tr[1]//td[2]' ).click ()
159
163
160
164
161
165
def check_all_approved (browser : webdriver .Chrome ) -> bool :
0 commit comments