11import sys
2+ from contextlib import suppress
23from seleniumbase import BaseCase
34from seleniumbase import SB
45BaseCase .main (__name__ , __file__ )
@@ -54,7 +55,7 @@ def test_presentation_3(self):
5455 )
5556 self .begin_presentation (filename = "uc_presentation.html" )
5657
57- try :
58+ with suppress ( Exception ) :
5859 with SB (uc = True ) as sb :
5960 url = "https://gitlab.com/users/sign_in"
6061 sb .uc_open_with_reconnect (url , 4 )
@@ -63,8 +64,6 @@ def test_presentation_3(self):
6364 sb .highlight ('button:contains("Sign in")' )
6465 sb .highlight ('h1:contains("GitLab.com")' )
6566 sb .post_message ("SeleniumBase wasn't detected" , duration = 4 )
66- except Exception :
67- pass
6867
6968 self .create_presentation (theme = "serif" , transition = "none" )
7069 self .add_slide (
@@ -151,16 +150,14 @@ def test_presentation_3(self):
151150 if "linux" in sys .platform or "win32" in sys .platform :
152151 agent = None # Use the default UserAgent
153152
154- try :
153+ with suppress ( Exception ) :
155154 with SB (uc = True , test = True , agent = agent ) as sb :
156155 url = "https://gitlab.com/users/sign_in"
157156 sb .uc_open_with_reconnect (url , 4 )
158157 sb .uc_gui_handle_captcha () # Only if needed
159158 sb .assert_element ('label[for="user_login"]' )
160159 sb .set_messenger_theme (location = "bottom_center" )
161160 sb .post_message ("SeleniumBase wasn't detected!" )
162- except Exception :
163- pass
164161
165162 self .create_presentation (theme = "serif" , transition = "none" )
166163 self .add_slide (
@@ -201,16 +198,14 @@ def test_presentation_3(self):
201198 )
202199 self .begin_presentation (filename = "uc_presentation.html" )
203200
204- try :
201+ with suppress ( Exception ) :
205202 with SB (uc = True , test = True , agent = agent ) as sb :
206203 url = "https://gitlab.com/users/sign_in"
207204 sb .uc_open_with_reconnect (url , 4 )
208205 sb .uc_gui_click_captcha () # Only if needed
209206 sb .assert_element ('label[for="user_login"]' )
210207 sb .set_messenger_theme (location = "bottom_center" )
211208 sb .post_message ("SeleniumBase wasn't detected!" )
212- except Exception :
213- pass
214209
215210 self .create_presentation (theme = "serif" , transition = "none" )
216211 self .add_slide (
@@ -276,7 +271,7 @@ def test_presentation_3(self):
276271 )
277272 self .begin_presentation (filename = "uc_presentation.html" )
278273
279- try :
274+ with suppress ( Exception ) :
280275 with SB (uc = True , incognito = True , locale_code = "en" ) as sb :
281276 url = "https://ahrefs.com/website-authority-checker"
282277 input_field = 'input[placeholder="Enter domain"]'
@@ -291,8 +286,6 @@ def test_presentation_3(self):
291286 sb .highlight ('a:contains("Top 100 backlinks")' )
292287 sb .set_messenger_theme (location = "bottom_center" )
293288 sb .post_message ("SeleniumBase wasn't detected!" )
294- except Exception :
295- pass
296289
297290 self .create_presentation (theme = "serif" , transition = "none" )
298291 self .add_slide (
@@ -312,7 +305,7 @@ def test_presentation_3(self):
312305 )
313306 self .begin_presentation (filename = "uc_presentation.html" )
314307
315- try :
308+ with suppress ( Exception ) :
316309 with SB (uc = True , test = True , disable_csp = True ) as sb :
317310 url = "https://steamdb.info/"
318311 sb .uc_open_with_reconnect (url , 3 )
@@ -324,8 +317,6 @@ def test_presentation_3(self):
324317 sb .highlight ('button:contains("Sign in")' , scroll = False )
325318 sb .set_messenger_theme (location = "top_center" )
326319 sb .post_message ("SeleniumBase wasn't detected" , duration = 4 )
327- except Exception :
328- pass
329320
330321 self .create_presentation (theme = "serif" , transition = "none" )
331322 self .add_slide (
@@ -405,16 +396,14 @@ def test_presentation_3(self):
405396 )
406397 self .begin_presentation (filename = "uc_presentation.html" )
407398
408- try :
399+ with suppress ( Exception ) :
409400 with SB (uc = True , test = True ) as sb :
410401 url = "https://seleniumbase.io/apps/recaptcha"
411402 sb .uc_open_with_reconnect (url )
412403 sb .uc_gui_click_captcha () # Try with PyAutoGUI Click
413404 sb .assert_element ("img#captcha-success" , timeout = 3 )
414405 sb .set_messenger_theme (location = "top_left" )
415406 sb .post_message ("SeleniumBase wasn't detected" )
416- except Exception :
417- pass
418407
419408 self .create_presentation (theme = "serif" , transition = "none" )
420409 self .add_slide (
@@ -673,7 +662,7 @@ def test_presentation_3(self):
673662 )
674663 self .begin_presentation (filename = "uc_presentation.html" )
675664
676- try :
665+ with suppress ( Exception ) :
677666 with SB (test = True ) as sb :
678667 url = "https://seleniumbase.io/hobbit/login"
679668 sb .open (url )
@@ -682,8 +671,6 @@ def test_presentation_3(self):
682671 sb .click ("img" )
683672 sb .highlight ("h1" )
684673 sb .sleep (3 ) # Gandalf: "You Shall Not Pass!"
685- except Exception :
686- pass
687674
688675 self .create_presentation (theme = "serif" , transition = "none" )
689676 self .add_slide (
@@ -692,7 +679,7 @@ def test_presentation_3(self):
692679 )
693680 self .begin_presentation (filename = "uc_presentation.html" )
694681
695- try :
682+ with suppress ( Exception ) :
696683 with SB (uc = True , test = True ) as sb :
697684 url = "https://seleniumbase.io/hobbit/login"
698685 sb .uc_open_with_disconnect (url , 2.2 )
@@ -703,8 +690,6 @@ def test_presentation_3(self):
703690 sb .post_message ("SeleniumBase wasn't detected!" )
704691 sb .click ("img" )
705692 sb .sleep (5.888 ) # Cool animation happening now!
706- except Exception :
707- pass
708693
709694 self .create_presentation (theme = "serif" , transition = "none" )
710695 self .add_slide (
0 commit comments