Skip to content

Commit 6e76e1f

Browse files
committed
Handle cases where "w3c" must be explicitly set to True
1 parent a625b24 commit 6e76e1f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,6 +2159,19 @@ def get_local_driver(
21592159
auto_upgrade_chromedriver = True
21602160
elif "Chrome version must be between" in e.msg:
21612161
auto_upgrade_chromedriver = True
2162+
elif "Missing or invalid capabilities" in e.msg:
2163+
if selenium4_or_newer:
2164+
chrome_options.add_experimental_option("w3c", True)
2165+
service = ChromeService(log_path=os.devnull)
2166+
with warnings.catch_warnings():
2167+
warnings.simplefilter(
2168+
"ignore", category=DeprecationWarning
2169+
)
2170+
return webdriver.Chrome(
2171+
service=service, options=chrome_options
2172+
)
2173+
else:
2174+
raise
21622175
if not auto_upgrade_chromedriver:
21632176
raise # Not an obvious fix.
21642177
else:
@@ -2257,6 +2270,19 @@ def get_local_driver(
22572270
auto_upgrade_chromedriver = True
22582271
elif "Chrome version must be between" in e.msg:
22592272
auto_upgrade_chromedriver = True
2273+
elif "Missing or invalid capabilities" in e.msg:
2274+
if selenium4_or_newer:
2275+
chrome_options.add_experimental_option("w3c", True)
2276+
service = ChromeService(log_path=os.devnull)
2277+
with warnings.catch_warnings():
2278+
warnings.simplefilter(
2279+
"ignore", category=DeprecationWarning
2280+
)
2281+
return webdriver.Chrome(
2282+
service=service, options=chrome_options
2283+
)
2284+
else:
2285+
raise
22602286
mcv = None # Major Chrome Version
22612287
if "Current browser version is " in e.msg:
22622288
line = e.msg.split("Current browser version is ")[1]

0 commit comments

Comments
 (0)