Skip to content

Commit 1c503bd

Browse files
committed
Update CDP Mode
1 parent 71a081e commit 1c503bd

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

seleniumbase/core/browser_launcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
766766
cdp.get_rd_port = CDPM.get_rd_port
767767
cdp.get_rd_url = CDPM.get_rd_url
768768
cdp.get_endpoint_url = CDPM.get_endpoint_url
769+
cdp.get_websocket_url = CDPM.get_websocket_url
769770
cdp.get_port = CDPM.get_port
770771
cdp.find_element = CDPM.find_element
771772
cdp.find = CDPM.find_element

seleniumbase/core/sb_cdp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ def get_port(self):
206206
"""Same as get_rd_port(), which returns the remote-debugging port."""
207207
return self.get_rd_port()
208208

209+
def get_websocket_url(self):
210+
"""Returns the websocket URL of the active tab.
211+
The websocket URL starts with `ws://`."""
212+
return self.get_active_tab().websocket_url
213+
209214
def add_handler(self, event, handler):
210215
self.page.add_handler(event, handler)
211216

seleniumbase/undetected/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def __init__(
179179
options.add_argument("--remote-debugging-host=%s" % debug_host)
180180
options.add_argument("--remote-debugging-port=%s" % debug_port)
181181
if user_data_dir:
182+
user_data_dir = os.path.abspath(user_data_dir)
182183
options.add_argument("--user-data-dir=%s" % user_data_dir)
183184
language, keep_user_data_dir = None, bool(user_data_dir)
184185
# See if a custom user profile is specified in options

seleniumbase/undetected/cdp_driver/cdp_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ async def start(
566566
platform_var = platform_var[1:-1]
567567
if IS_LINUX and not headless and not headed and not xvfb:
568568
xvfb = True # The default setting on Linux
569+
if port and not host:
570+
host = "127.0.0.1" # Assume localhost
569571
if not host or not port:
570572
# The browser hasn't been launched yet. (May need a virtual display)
571573
__activate_virtual_display_as_needed(
@@ -611,6 +613,8 @@ async def start(
611613
elif udd_string.startswith("'") and udd_string.endswith("'"):
612614
udd_string = udd_string[1:-1]
613615
user_data_dir = udd_string
616+
if user_data_dir:
617+
user_data_dir = os.path.abspath(user_data_dir)
614618
if not browser_executable_path:
615619
browser = None
616620
if "browser" in kwargs:

0 commit comments

Comments
 (0)