9
9
from selenium .common .exceptions import NoSuchElementException
10
10
from selenium .webdriver .chrome .options import Options as ChromiumOptions
11
11
from selenium .webdriver .common .by import By
12
+ from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
12
13
from utils import TestUtilities
13
14
14
15
@@ -120,13 +121,17 @@ def setUpClass(cls):
120
121
)
121
122
# Create base drivers (Chromium)
122
123
if cls .config ['driver' ] == 'chromium' :
123
- chrome_options = ChromiumOptions ()
124
- chrome_options . set_capability ( "goog:loggingPrefs" , { 'browser' : 'ALL' } )
125
- chrome_options .add_argument ('--ignore-certificate-errors' )
124
+ options = ChromiumOptions ()
125
+ options . add_argument ( '--headless' )
126
+ options .add_argument ('--ignore-certificate-errors' )
126
127
if cls .config ['headless' ]:
127
- chrome_options .add_argument ('--headless' )
128
- cls .base_driver = webdriver .Chrome (options = chrome_options )
129
- cls .second_driver = webdriver .Chrome (options = chrome_options )
128
+ options .add_argument ('--headless' )
129
+ options .add_argument (f'--remote-debugging-port={ 5003 + 100 } ' )
130
+ capabilities = DesiredCapabilities .CHROME
131
+ capabilities ['goog:loggingPrefs' ] = {'browser' : 'ALL' }
132
+ options .set_capability ('cloud:options' , capabilities )
133
+ cls .base_driver = webdriver .Chrome (options = options )
134
+ cls .second_driver = webdriver .Chrome (options = options )
130
135
cls .base_driver .set_window_size (1366 , 768 )
131
136
cls .second_driver .set_window_size (1366 , 768 )
132
137
@@ -137,8 +142,8 @@ def tearDownClass(cls):
137
142
cls ._delete_object (resource_link )
138
143
except NoSuchElementException :
139
144
print (f'Unable to delete resource at: { resource_link } ' )
140
- cls .second_driver .close ()
141
- cls .base_driver .close ()
145
+ cls .second_driver .quit ()
146
+ cls .base_driver .quit ()
142
147
if cls .failed_test and cls .config ['logs' ]:
143
148
cmd = subprocess .Popen (
144
149
['docker-compose' , 'logs' ],
@@ -170,8 +175,9 @@ def test_topology_graph(self):
170
175
self .action_on_resource (label , path , 'delete_selected' )
171
176
self .assertNotIn ('<li>Nodes: ' , self .base_driver .page_source )
172
177
self .action_on_resource (label , path , 'update_selected' )
173
- time . sleep ( 4 ) # Wait for nodes to be fetched!
178
+
174
179
self .action_on_resource (label , path , 'delete_selected' )
180
+ self ._wait_for_element ()
175
181
self .assertIn ('<li>Nodes: ' , self .base_driver .page_source )
176
182
177
183
def test_admin_login (self ):
@@ -194,21 +200,21 @@ def test_create_prefix_users(self):
194
200
self .base_driver .get (
195
201
f"{ self .config ['app_url' ]} /admin/openwisp_radius/radiusbatch/add/"
196
202
)
197
- self .base_driver .find_element_by_name ( 'strategy' ).find_element_by_xpath (
198
- '//option[@value="prefix"]'
203
+ self .base_driver .find_element ( By . NAME , 'strategy' ).find_element (
204
+ By . XPATH , '//option[@value="prefix"]'
199
205
).click ()
200
- self .base_driver .find_element_by_name ( 'organization' ).find_element_by_xpath (
201
- '//option[text()="default"]'
206
+ self .base_driver .find_element ( By . NAME , 'organization' ).find_element (
207
+ By . XPATH , '//option[text()="default"]'
202
208
).click ()
203
- self .base_driver .find_element_by_name ( 'name' ).send_keys (prefix_objname )
204
- self .base_driver .find_element_by_name ( 'prefix' ).send_keys ('automated-prefix' )
205
- self .base_driver .find_element_by_name ( 'number_of_users' ).send_keys ('1' )
206
- self .base_driver .find_element_by_name ( '_save' ).click ()
209
+ self .base_driver .find_element ( By . NAME , 'name' ).send_keys (prefix_objname )
210
+ self .base_driver .find_element ( By . NAME , 'prefix' ).send_keys ('automated-prefix' )
211
+ self .base_driver .find_element ( By . NAME , 'number_of_users' ).send_keys ('1' )
212
+ self .base_driver .find_element ( By . NAME , '_save' ).click ()
207
213
# Check PDF available
208
214
self .get_resource (prefix_objname , '/admin/openwisp_radius/radiusbatch/' )
209
215
self .objects_to_delete .append (self .base_driver .current_url )
210
- prefix_pdf_file_path = self .base_driver .find_element_by_xpath (
211
- '//a[text()="Download User Credentials"]'
216
+ prefix_pdf_file_path = self .base_driver .find_element (
217
+ By . XPATH , '//a[text()="Download User Credentials"]'
212
218
).get_property ('href' )
213
219
reqHeader = {
214
220
'Cookie' : f"sessionid={ self .base_driver .get_cookies ()[0 ]['value' ]} "
@@ -314,6 +320,7 @@ def test_forgot_password(self):
314
320
self .base_driver .get (f"{ self .config ['app_url' ]} /accounts/password/reset/" )
315
321
self .
base_driver .
find_element (
By .
NAME ,
'email' ).
send_keys (
'[email protected] ' )
316
322
self .base_driver .find_element (By .XPATH , '//input[@type="submit"]' ).click ()
323
+ self ._wait_for_element ()
317
324
self .assertIn (
318
325
'We have sent you an e-mail. If you have not received '
319
326
'it please check your spam folder. Otherwise contact us '
@@ -355,13 +362,14 @@ def test_celery(self):
355
362
"openwisp_monitoring.check.tasks.run_checks" ,
356
363
"openwisp_monitoring.device.tasks.delete_wifi_clients_and_sessions" ,
357
364
"openwisp_monitoring.device.tasks.offline_device_close_session" ,
358
- "openwisp_monitoring.device.tasks.save_wifi_clients_and_sessions" ,
359
365
"openwisp_monitoring.device.tasks.trigger_device_checks" ,
360
366
"openwisp_monitoring.device.tasks.write_device_metrics" ,
367
+ "openwisp_monitoring.device.tasks.handle_disabled_organization" ,
361
368
"openwisp_monitoring.monitoring.tasks.delete_timeseries" ,
362
369
"openwisp_monitoring.monitoring.tasks.migrate_timeseries_database" ,
363
370
"openwisp_monitoring.monitoring.tasks.timeseries_batch_write" ,
364
371
"openwisp_monitoring.monitoring.tasks.timeseries_write" ,
372
+ "openwisp_monitoring.monitoring.tasks.delete_timeseries" ,
365
373
"openwisp_notifications.tasks.delete_ignore_object_notification" ,
366
374
"openwisp_notifications.tasks.delete_notification" ,
367
375
"openwisp_notifications.tasks.delete_obsolete_objects" ,
@@ -392,8 +400,8 @@ def _test_celery_task_registered(container_name):
392
400
for expected_output in expected_output_list :
393
401
if expected_output not in output :
394
402
self .fail (
395
- 'Not all celery / celery-beat tasks are registered\n '
396
- f'Output :\n { output } \n '
403
+ 'Not all celery / celery-beat tasks are registered. \n '
404
+ f'Expected celery task not found :\n { expected_output } '
397
405
)
398
406
399
407
with self .subTest ('Test celery container' ):
0 commit comments