Skip to content

Commit d2d2ba8

Browse files
committed
Do some refactoring
1 parent 3d9f0ea commit d2d2ba8

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

seleniumbase/fixtures/shared_utils.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,46 +81,46 @@ def format_exc(exception, message):
8181
from seleniumbase.common.exceptions import TextNotVisibleException
8282
from seleniumbase.common import exceptions
8383

84-
if exception == Exception:
84+
if exception is Exception:
8585
exc = Exception
8686
return exc, message
87-
elif exception == ElementNotVisibleException:
87+
elif exception is ElementNotVisibleException:
8888
exc = exceptions.ElementNotVisibleException
8989
elif exception == "ElementNotVisibleException":
9090
exc = exceptions.ElementNotVisibleException
91-
elif exception == LinkTextNotFoundException:
91+
elif exception is LinkTextNotFoundException:
9292
exc = exceptions.LinkTextNotFoundException
9393
elif exception == "LinkTextNotFoundException":
9494
exc = exceptions.LinkTextNotFoundException
95-
elif exception == NoSuchElementException:
95+
elif exception is NoSuchElementException:
9696
exc = exceptions.NoSuchElementException
9797
elif exception == "NoSuchElementException":
9898
exc = exceptions.NoSuchElementException
99-
elif exception == TextNotVisibleException:
99+
elif exception is TextNotVisibleException:
100100
exc = exceptions.TextNotVisibleException
101101
elif exception == "TextNotVisibleException":
102102
exc = exceptions.TextNotVisibleException
103-
elif exception == NoAlertPresentException:
103+
elif exception is NoAlertPresentException:
104104
exc = exceptions.NoAlertPresentException
105105
elif exception == "NoAlertPresentException":
106106
exc = exceptions.NoAlertPresentException
107-
elif exception == NoSuchAttributeException:
107+
elif exception is NoSuchAttributeException:
108108
exc = exceptions.NoSuchAttributeException
109109
elif exception == "NoSuchAttributeException":
110110
exc = exceptions.NoSuchAttributeException
111-
elif exception == NoSuchFrameException:
111+
elif exception is NoSuchFrameException:
112112
exc = exceptions.NoSuchFrameException
113113
elif exception == "NoSuchFrameException":
114114
exc = exceptions.NoSuchFrameException
115-
elif exception == NoSuchWindowException:
115+
elif exception is NoSuchWindowException:
116116
exc = exceptions.NoSuchWindowException
117117
elif exception == "NoSuchWindowException":
118118
exc = exceptions.NoSuchWindowException
119-
elif exception == NoSuchFileException:
119+
elif exception is NoSuchFileException:
120120
exc = exceptions.NoSuchFileException
121121
elif exception == "NoSuchFileException":
122122
exc = exceptions.NoSuchFileException
123-
elif exception == NoSuchOptionException:
123+
elif exception is NoSuchOptionException:
124124
exc = exceptions.NoSuchOptionException
125125
elif exception == "NoSuchOptionException":
126126
exc = exceptions.NoSuchOptionException

seleniumbase/plugins/driver_manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def Driver(
125125
uc_cdp=None, # Shortcut / Duplicate of "uc_cdp_events".
126126
uc_sub=None, # Shortcut / Duplicate of "uc_subprocess".
127127
log_cdp=None, # Shortcut / Duplicate of "log_cdp_events".
128+
ad_block=None, # Shortcut / Duplicate of "ad_block_on".
128129
server=None, # Shortcut / Duplicate of "servername".
130+
guest=None, # Shortcut / Duplicate of "guest_mode".
129131
wire=None, # Shortcut / Duplicate of "use_wire".
130132
pls=None, # Shortcut / Duplicate of "page_load_strategy".
131133
):
@@ -263,6 +265,8 @@ def Driver(
263265
incognito = True
264266
else:
265267
incognito = False
268+
if guest is not None and guest_mode is None:
269+
guest_mode = guest
266270
if guest_mode is None:
267271
if "--guest" in sys_argv:
268272
guest_mode = True
@@ -515,6 +519,8 @@ def Driver(
515519
swiftshader = True
516520
else:
517521
swiftshader = False
522+
if ad_block is not None and ad_block_on is None:
523+
ad_block_on = ad_block
518524
if ad_block_on is None:
519525
if "--ad-block" in sys_argv or "--ad_block" in sys_argv:
520526
ad_block_on = True

seleniumbase/plugins/sb_manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ def SB(
103103
uc_cdp=None, # Shortcut / Duplicate of "uc_cdp_events".
104104
uc_sub=None, # Shortcut / Duplicate of "uc_subprocess".
105105
log_cdp=None, # Shortcut / Duplicate of "log_cdp_events".
106+
ad_block=None, # Shortcut / Duplicate of "ad_block_on".
106107
server=None, # Shortcut / Duplicate of "servername".
108+
guest=None, # Shortcut / Duplicate of "guest_mode".
107109
wire=None, # Shortcut / Duplicate of "use_wire".
108110
pls=None, # Shortcut / Duplicate of "page_load_strategy".
109111
sjw=None, # Shortcut / Duplicate of "skip_js_waits".
@@ -296,6 +298,8 @@ def SB(
296298
incognito = True
297299
else:
298300
incognito = False
301+
if guest is not None and guest_mode is None:
302+
guest_mode = guest
299303
if guest_mode is None:
300304
if "--guest" in sys_argv:
301305
guest_mode = True
@@ -659,6 +663,8 @@ def SB(
659663
swiftshader = True
660664
else:
661665
swiftshader = False
666+
if ad_block is not None and ad_block_on is None:
667+
ad_block_on = ad_block
662668
if ad_block_on is None:
663669
if "--ad-block" in sys_argv or "--ad_block" in sys_argv:
664670
ad_block_on = True

0 commit comments

Comments
 (0)