@@ -89,60 +89,79 @@ def test_download_file(self):
8989 self .assertTrue (str (driver .get_downloadable_files ()[0 ]).endswith (file_name ))
9090
9191 def tearDown (self ):
92- self .driver .quit ()
92+ try :
93+ self .driver .quit ()
94+ except Exception as e :
95+ print (f"::error::Exception: { str (e )} " )
96+ print (traceback .format_exc ())
97+ raise e
9398
9499
95100class ChromeTests (SeleniumGenericTests ):
96101 def setUp (self ):
97- options = ChromeOptions ()
98- options .enable_downloads = True
99- options .add_argument ('disable-features=DownloadBubble,DownloadBubbleV2' )
100- options .set_capability ('se:recordVideo' , True )
101- if SELENIUM_GRID_TEST_HEADLESS :
102- options .add_argument ('--headless=new' )
103- start_time = time .time ()
104- self .driver = webdriver .Remote (
105- options = options ,
106- command_executor = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL ,SELENIUM_GRID_HOST ,SELENIUM_GRID_PORT )
107- )
108- end_time = time .time ()
109- print (f"<< { self ._testMethodName } ({ self .__class__ .__name__ } ) WebDriver initialization completed in { end_time - start_time } (s)" )
102+ try :
103+ options = ChromeOptions ()
104+ options .enable_downloads = True
105+ options .add_argument ('disable-features=DownloadBubble,DownloadBubbleV2' )
106+ options .set_capability ('se:recordVideo' , True )
107+ if SELENIUM_GRID_TEST_HEADLESS :
108+ options .add_argument ('--headless=new' )
109+ start_time = time .time ()
110+ self .driver = webdriver .Remote (
111+ options = options ,
112+ command_executor = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL ,SELENIUM_GRID_HOST ,SELENIUM_GRID_PORT )
113+ )
114+ end_time = time .time ()
115+ print (f"<< { self ._testMethodName } ({ self .__class__ .__name__ } ) WebDriver initialization completed in { end_time - start_time } (s)" )
116+ except Exception as e :
117+ print (f"::error::Exception: { str (e )} " )
118+ print (traceback .format_exc ())
119+ raise e
110120
111121class EdgeTests (SeleniumGenericTests ):
112122 def setUp (self ):
113- options = EdgeOptions ()
114- options .enable_downloads = True
115- options .add_argument ('disable-features=DownloadBubble,DownloadBubbleV2' )
116- options .set_capability ('se:recordVideo' , True )
117- if SELENIUM_GRID_TEST_HEADLESS :
118- options .add_argument ('--headless=new' )
119- start_time = time .time ()
120- self .driver = webdriver .Remote (
121- options = options ,
122- command_executor = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL ,SELENIUM_GRID_HOST ,SELENIUM_GRID_PORT )
123- )
124- end_time = time .time ()
125- print (f"<< { self ._testMethodName } ({ self .__class__ .__name__ } ) WebDriver initialization completed in { end_time - start_time } (s)" )
126-
123+ try :
124+ options = EdgeOptions ()
125+ options .enable_downloads = True
126+ options .add_argument ('disable-features=DownloadBubble,DownloadBubbleV2' )
127+ options .set_capability ('se:recordVideo' , True )
128+ if SELENIUM_GRID_TEST_HEADLESS :
129+ options .add_argument ('--headless=new' )
130+ start_time = time .time ()
131+ self .driver = webdriver .Remote (
132+ options = options ,
133+ command_executor = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL ,SELENIUM_GRID_HOST ,SELENIUM_GRID_PORT )
134+ )
135+ end_time = time .time ()
136+ print (f"<< { self ._testMethodName } ({ self .__class__ .__name__ } ) WebDriver initialization completed in { end_time - start_time } (s)" )
137+ except Exception as e :
138+ print (f"::error::Exception: { str (e )} " )
139+ print (traceback .format_exc ())
140+ raise e
127141
128142class FirefoxTests (SeleniumGenericTests ):
129143 def setUp (self ):
130- profile = webdriver .FirefoxProfile ()
131- profile .set_preference ("browser.download.manager.showWhenStarting" , False )
132- profile .set_preference ("browser.helperApps.neverAsk.saveToDisk" , "*/*" )
133- options = FirefoxOptions ()
134- options .profile = profile
135- options .enable_downloads = True
136- options .set_capability ('se:recordVideo' , True )
137- if SELENIUM_GRID_TEST_HEADLESS :
138- options .add_argument ('-headless' )
139- start_time = time .time ()
140- self .driver = webdriver .Remote (
141- options = options ,
142- command_executor = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL ,SELENIUM_GRID_HOST ,SELENIUM_GRID_PORT )
143- )
144- end_time = time .time ()
145- print (f"<< { self ._testMethodName } ({ self .__class__ .__name__ } ) WebDriver initialization completed in { end_time - start_time } (s)" )
144+ try :
145+ profile = webdriver .FirefoxProfile ()
146+ profile .set_preference ("browser.download.manager.showWhenStarting" , False )
147+ profile .set_preference ("browser.helperApps.neverAsk.saveToDisk" , "*/*" )
148+ options = FirefoxOptions ()
149+ options .profile = profile
150+ options .enable_downloads = True
151+ options .set_capability ('se:recordVideo' , True )
152+ if SELENIUM_GRID_TEST_HEADLESS :
153+ options .add_argument ('-headless' )
154+ start_time = time .time ()
155+ self .driver = webdriver .Remote (
156+ options = options ,
157+ command_executor = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL ,SELENIUM_GRID_HOST ,SELENIUM_GRID_PORT )
158+ )
159+ end_time = time .time ()
160+ print (f"<< { self ._testMethodName } ({ self .__class__ .__name__ } ) WebDriver initialization completed in { end_time - start_time } (s)" )
161+ except Exception as e :
162+ print (f"::error::Exception: { str (e )} " )
163+ print (traceback .format_exc ())
164+ raise e
146165
147166 def test_title_and_maximize_window (self ):
148167 self .driver .get ('https://the-internet.herokuapp.com' )
0 commit comments