Skip to content

Commit 082c692

Browse files
committed
Fix an issue with the remote-debugging-port in UC Mode
1 parent 4e827a1 commit 082c692

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,14 @@ def _set_chrome_options(
711711
chromium_arg_item = "-" + chromium_arg_item
712712
else:
713713
chromium_arg_item = "--" + chromium_arg_item
714+
if "remote-debugging-port=" in chromium_arg_item:
715+
try:
716+
# Extra processing for UC Mode
717+
chrome_options._remote_debugging_port = int(
718+
chromium_arg_item.split("remote-debugging-port=")[1]
719+
)
720+
except Exception:
721+
pass
714722
if len(chromium_arg_item) >= 3:
715723
chrome_options.add_argument(chromium_arg_item)
716724
if devtools and not headless:

seleniumbase/undetected/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,15 @@ def __init__(
134134
options = ChromeOptions()
135135
try:
136136
if hasattr(options, "_session") and options._session is not None:
137-
# Prevent reuse of options
137+
# Prevent reuse of options
138138
raise RuntimeError("you cannot reuse the ChromeOptions object")
139139
except AttributeError:
140140
pass
141141
options._session = self
142-
debug_port = selenium.webdriver.common.service.utils.free_port()
143142
debug_host = "127.0.0.1"
143+
debug_port = 9222
144+
if hasattr(options, "_remote_debugging_port"):
145+
debug_port = options._remote_debugging_port
144146
if not options.debugger_address:
145147
options.debugger_address = "%s:%d" % (debug_host, debug_port)
146148
if enable_cdp_events:

0 commit comments

Comments
 (0)