Skip to content

Commit 6795f36

Browse files
committed
[ci] Added sleep to selenium test
1 parent ffef8c1 commit 6795f36

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ jobs:
8989
if: ${{ failure() }}
9090
run: cat geckodriver.log
9191

92+
- name: Upload device files on failure
93+
if: ${{ failure() }}
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: device-files
97+
path: /tmp/delete_devices_error.png
98+
retention-days: 1
99+
overwrite: true
100+
92101
- name: Upload Coverage
93102
if: ${{ success() }}
94103
uses: coverallsapp/github-action@v2

openwisp_controller/config/tests/test_selenium.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)