Skip to content

Commit e50a457

Browse files
committed
[tests] Verify select is clickable
1 parent cc13a35 commit e50a457

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

openwisp_firmware_upgrader/tests/test_selenium.py

+14-20
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ def tearDown(self):
9797
EC.visibility_of_element_located((By.XPATH, '//*[@id="site-name"]'))
9898
)
9999

100+
def _get_device_firmware_dropdown_select(self):
101+
select_element = WebDriverWait(self.web_driver, 5).until(
102+
EC.element_to_be_clickable((By.ID, 'id_devicefirmware-0-image'))
103+
)
104+
return Select(select_element)
105+
100106
@capture_any_output()
101107
def test_restoring_deleted_device(self):
102108
org = self._get_org()
@@ -136,8 +142,10 @@ def test_restoring_deleted_device(self):
136142
f'admin:{self.config_app_label}_device_recover', args=[version_obj.id]
137143
)
138144
)
139-
self.web_driver.find_element(
140-
by=By.XPATH, value='//*[@id="device_form"]/div/div[1]/input[1]'
145+
WebDriverWait(self.web_driver, 5).until(
146+
EC.element_to_be_clickable(
147+
(By.XPATH, '//*[@id="device_form"]/div/div[1]/input[1]')
148+
)
141149
).click()
142150
try:
143151
WebDriverWait(self.web_driver, 5).until(
@@ -150,7 +158,7 @@ def test_restoring_deleted_device(self):
150158
self.assertEqual(DeviceConnection.objects.count(), 1)
151159
self.assertEqual(DeviceFirmware.objects.count(), 1)
152160

153-
@capture_any_output()
161+
# @capture_any_output()
154162
@patch(
155163
'openwisp_firmware_upgrader.upgraders.openwrt.OpenWrt.upgrade',
156164
return_value=True,
@@ -174,18 +182,13 @@ def save_device():
174182
)
175183
)
176184
)
177-
WebDriverWait(self.web_driver, 1).until(
178-
EC.invisibility_of_element_located((By.CSS_SELECTOR, '#loading-overlay'))
179-
)
180185
# JSONSchema Editor should not be rendered without a change in the image field
181186
WebDriverWait(self.web_driver, 1).until(
182187
EC.invisibility_of_element_located(
183188
(By.CSS_SELECTOR, '#devicefirmware-group .jsoneditor-wrapper')
184189
)
185190
)
186-
image_select = Select(
187-
self.web_driver.find_element(by=By.ID, value='id_devicefirmware-0-image')
188-
)
191+
image_select = self._get_device_firmware_dropdown_select()
189192
image_select.select_by_value(str(image.pk))
190193
# JSONSchema configuration editor should not be rendered
191194
WebDriverWait(self.web_driver, 1).until(
@@ -238,9 +241,7 @@ def save_device():
238241
(By.CSS_SELECTOR, '#devicefirmware-group .jsoneditor-wrapper')
239242
)
240243
)
241-
image_select = Select(
242-
self.web_driver.find_element(by=By.ID, value='id_devicefirmware-0-image')
243-
)
244+
image_select = self._get_device_firmware_dropdown_select()
244245
image_select.select_by_index(1)
245246
try:
246247
WebDriverWait(self.web_driver, 1).until(
@@ -362,14 +363,7 @@ def test_upgrader_with_unsupported_upgrade_options(self, *args):
362363
)
363364
)
364365
)
365-
WebDriverWait(self.web_driver, 5).until(
366-
EC.visibility_of_element_located((By.ID, 'id_devicefirmware-0-image'))
367-
)
368-
image_select = Select(
369-
self.web_driver.find_element(
370-
by=By.ID, value='id_devicefirmware-0-image'
371-
)
372-
)
366+
image_select = self._get_device_firmware_dropdown_select()
373367
image_select.select_by_value(str(image2.pk))
374368
# Ensure JSONSchema editor is not rendered because
375369
# the upgrader does not define a schema

0 commit comments

Comments
 (0)