@@ -252,10 +252,16 @@ def test_force_delete_device_with_deactivating_config(self):
252252 # to complete before trying to interact with the button,
253253 # otherwise the test may fail due to the button not being fully
254254 # visible or clickable yet.
255- time .sleep (0.5 )
256- delete_confirm = self .find_element (
257- By .CSS_SELECTOR , 'form[method="post"] input[type="submit"]' , timeout = 10
258- )
255+ time .sleep (1 )
256+ try :
257+ delete_confirm = self .find_element (
258+ By .CSS_SELECTOR , 'form[method="post"] input[type="submit"]'
259+ )
260+ except Exception as e :
261+ # Take a screenshot of the failed state
262+ screenshot_path = '/tmp/delete_devices_error.png'
263+ self .web_driver .save_screenshot (screenshot_path )
264+ raise e
259265 delete_confirm .click ()
260266 self .assertEqual (Device .objects .count (), 0 )
261267
@@ -285,9 +291,20 @@ def test_force_delete_multiple_devices_with_deactivating_config(self):
285291 By .CSS_SELECTOR , '#deactivating-warning .messagelist .warning p'
286292 )
287293 self .find_element (by = By .CSS_SELECTOR , value = '#warning-ack' ).click ()
288- delete_confirm = self .find_element (
289- By .CSS_SELECTOR , 'form[method="post"] input[type="submit"]'
290- )
294+ # After accepting the warning, wee need to wait for the animation
295+ # to complete before trying to interact with the button,
296+ # otherwise the test may fail due to the button not being fully
297+ # visible or clickable yet.
298+ time .sleep (1 )
299+ try :
300+ delete_confirm = self .find_element (
301+ By .CSS_SELECTOR , 'form[method="post"] input[type="submit"]'
302+ )
303+ except Exception as e :
304+ # Take a screenshot of the failed state
305+ screenshot_path = '/tmp/delete_devices_error.png'
306+ self .web_driver .save_screenshot (screenshot_path )
307+ raise e
291308 delete_confirm .click ()
292309 self .assertEqual (Device .objects .count (), 0 )
293310
0 commit comments