Skip to content

Commit 6436c0e

Browse files
committed
[tests] Made selenium test resilient to failures
1 parent 3a52919 commit 6436c0e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

openwisp_firmware_upgrader/tests/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class TestUpgraderMixin(CreateConnectionsMixin):
2626
)
2727

2828
def tearDown(self):
29+
super().tearDown()
2930
for fw in FirmwareImage.objects.all():
3031
fw.delete()
3132

openwisp_firmware_upgrader/tests/test_selenium.py

+15
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def setUp(self):
5353
)
5454

5555
def tearDown(self):
56+
super().tearDown()
5657
# Accept unsaved changes alert to allow other tests to run
5758
try:
5859
self.web_driver.refresh()
@@ -147,6 +148,11 @@ def save_device():
147148
)
148149
)
149150
)
151+
WebDriverWait(self.web_driver, 1).until(
152+
EC.invisibility_of_element_located(
153+
(By.CSS_SELECTOR, '#loading-overlay')
154+
)
155+
)
150156
# JSONSchema Editor should not be rendered without a change in the image field
151157
WebDriverWait(self.web_driver, 1).until(
152158
EC.invisibility_of_element_located(
@@ -275,6 +281,12 @@ def test_batch_upgrade_upgrade_options(self, *args):
275281
self.web_driver.find_element(
276282
by=By.CSS_SELECTOR, value='input[name="upgrade_all"]'
277283
).click()
284+
try:
285+
WebDriverWait(self.web_driver, 5).until(
286+
EC.url_contains('batchupgradeoperation')
287+
)
288+
except TimeoutException:
289+
self.fail('User was not redirected to Mass upgrade operations page')
278290
self.assertEqual(
279291
BatchUpgradeOperation.objects.filter(
280292
upgrade_options={
@@ -326,6 +338,9 @@ def test_upgrader_with_unsupported_upgrade_options(self, *args):
326338
)
327339
)
328340
)
341+
WebDriverWait(self.web_driver, 5).until(
342+
EC.visibility_of_element_located((By.ID, 'id_devicefirmware-0-image'))
343+
)
329344
image_select = Select(
330345
self.web_driver.find_element(
331346
by=By.ID, value='id_devicefirmware-0-image'

0 commit comments

Comments
 (0)