Skip to content

Commit c508f38

Browse files
committed
Refactoring
1 parent 3a46d83 commit c508f38

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,10 +1566,10 @@ def get_local_driver(
15661566
options=firefox_options,
15671567
)
15681568
else:
1569-
raise Exception(e.msg) # Not an obvious fix.
1569+
raise # Not an obvious fix.
15701570
else:
15711571
return webdriver.Firefox(
1572-
service_log_path=os.path.devnull,
1572+
service_log_path=os.devnull,
15731573
options=firefox_options,
15741574
)
15751575
elif browser_name == constants.Browser.INTERNET_EXPLORER:
@@ -1836,7 +1836,7 @@ def get_local_driver(
18361836
if selenium4:
18371837
try:
18381838
service = EdgeService(
1839-
executable_path=LOCAL_EDGEDRIVER, log_path=os.path.devnull
1839+
executable_path=LOCAL_EDGEDRIVER, log_path=os.devnull
18401840
)
18411841
driver = Edge(service=service, options=edge_options)
18421842
except Exception as e:
@@ -1856,13 +1856,13 @@ def get_local_driver(
18561856
elif "DevToolsActivePort file doesn't exist" in e.msg:
18571857
service = EdgeService(
18581858
executable_path=LOCAL_EDGEDRIVER,
1859-
log_path=os.path.devnull,
1859+
log_path=os.devnull,
18601860
)
18611861
# https://stackoverflow.com/a/56638103/7058266
18621862
edge_options.add_argument("--remote-debugging-port=9222")
18631863
return Edge(service=service, options=edge_options)
18641864
if not auto_upgrade_edgedriver:
1865-
raise Exception(e.msg) # Not an obvious fix. Raise.
1865+
raise # Not an obvious fix.
18661866
else:
18671867
pass # Try upgrading EdgeDriver to match Edge.
18681868
args = " ".join(sys.argv)
@@ -1881,7 +1881,7 @@ def get_local_driver(
18811881
_repair_edgedriver(edge_version)
18821882
_mark_driver_repaired()
18831883
service = EdgeService(
1884-
executable_path=LOCAL_EDGEDRIVER, log_path=os.path.devnull
1884+
executable_path=LOCAL_EDGEDRIVER, log_path=os.devnull
18851885
)
18861886
driver = Edge(service=service, options=edge_options)
18871887
return driver
@@ -1891,7 +1891,7 @@ def get_local_driver(
18911891
try:
18921892
driver = Edge(
18931893
executable_path=LOCAL_EDGEDRIVER,
1894-
service_log_path=os.path.devnull,
1894+
service_log_path=os.devnull,
18951895
capabilities=capabilities,
18961896
)
18971897
except Exception as e:
@@ -1911,13 +1911,13 @@ def get_local_driver(
19111911
elif "DevToolsActivePort file doesn't exist" in e.msg:
19121912
service = EdgeService(
19131913
executable_path=LOCAL_EDGEDRIVER,
1914-
log_path=os.path.devnull,
1914+
log_path=os.devnull,
19151915
)
19161916
# https://stackoverflow.com/a/56638103/7058266
19171917
edge_options.add_argument("--remote-debugging-port=9222")
19181918
return Edge(service=service, options=edge_options)
19191919
if not auto_upgrade_edgedriver:
1920-
raise Exception(e.msg) # Not an obvious fix. Raise.
1920+
raise # Not an obvious fix.
19211921
else:
19221922
pass # Try upgrading EdgeDriver to match Edge.
19231923
args = " ".join(sys.argv)
@@ -1937,7 +1937,7 @@ def get_local_driver(
19371937
_mark_driver_repaired()
19381938
driver = Edge(
19391939
executable_path=LOCAL_EDGEDRIVER,
1940-
service_log_path=os.path.devnull,
1940+
service_log_path=os.devnull,
19411941
capabilities=capabilities,
19421942
)
19431943
return driver
@@ -2092,7 +2092,7 @@ def get_local_driver(
20922092
if selenium4:
20932093
service = ChromeService(
20942094
executable_path=LOCAL_CHROMEDRIVER,
2095-
log_path=os.path.devnull,
2095+
log_path=os.devnull,
20962096
)
20972097
driver = webdriver.Chrome(
20982098
service=service,
@@ -2101,19 +2101,19 @@ def get_local_driver(
21012101
else:
21022102
driver = webdriver.Chrome(
21032103
executable_path=LOCAL_CHROMEDRIVER,
2104-
service_log_path=os.path.devnull,
2104+
service_log_path=os.devnull,
21052105
options=chrome_options,
21062106
)
21072107
else:
21082108
if selenium4:
2109-
service = ChromeService(log_path=os.path.devnull)
2109+
service = ChromeService(log_path=os.devnull)
21102110
driver = webdriver.Chrome(
21112111
service=service, options=chrome_options
21122112
)
21132113
else:
21142114
driver = webdriver.Chrome(
21152115
options=chrome_options,
2116-
service_log_path=os.path.devnull,
2116+
service_log_path=os.devnull,
21172117
)
21182118
except Exception as e:
21192119
auto_upgrade_chromedriver = False
@@ -2122,7 +2122,7 @@ def get_local_driver(
21222122
elif "Chrome version must be between" in e.msg:
21232123
auto_upgrade_chromedriver = True
21242124
if not auto_upgrade_chromedriver:
2125-
raise Exception(e.msg) # Not an obvious fix. Raise.
2125+
raise # Not an obvious fix.
21262126
else:
21272127
pass # Try upgrading ChromeDriver to match Chrome.
21282128
mcv = None # Major Chrome Version
@@ -2267,14 +2267,14 @@ def get_local_driver(
22672267
)
22682268
chrome_options.headless = False
22692269
return webdriver.Chrome(options=chrome_options)
2270-
except Exception as e:
2270+
except Exception:
22712271
try:
22722272
# Try again if Chrome didn't launch
22732273
return webdriver.Chrome(options=chrome_options)
22742274
except Exception:
22752275
pass
22762276
if headless:
2277-
raise Exception(e)
2277+
raise
22782278
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
22792279
try:
22802280
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)

0 commit comments

Comments
 (0)