File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -525,9 +525,6 @@ def uc_open_with_cdp_mode(driver, url=None):
525
525
js_utils .call_me_later (driver , script , 3 )
526
526
time .sleep (0.012 )
527
527
driver .close ()
528
- driver .clear_cdp_listeners ()
529
- driver .delete_all_cookies ()
530
- driver .delete_network_conditions ()
531
528
driver .disconnect ()
532
529
533
530
cdp_details = driver ._get_cdp_details ()
@@ -546,6 +543,7 @@ def uc_open_with_cdp_mode(driver, url=None):
546
543
cdp_util .start (host = cdp_host , port = cdp_port )
547
544
)
548
545
page = loop .run_until_complete (driver .cdp_base .get (url ))
546
+ loop .run_until_complete (page .activate ())
549
547
if not safe_url :
550
548
time .sleep (constants .UC .CDP_MODE_OPEN_WAIT )
551
549
cdp = types .SimpleNamespace ()
Original file line number Diff line number Diff line change @@ -133,8 +133,11 @@ def __init__(
133
133
options = ChromeOptions ()
134
134
try :
135
135
if hasattr (options , "_session" ) and options ._session is not None :
136
- # Prevent reuse of options
137
- raise RuntimeError ("You cannot reuse the ChromeOptions object" )
136
+ # Prevent reuse of options.
137
+ # (Probably a port overlap. Quit existing driver and continue.)
138
+ logger .debug ("You cannot reuse the ChromeOptions object" )
139
+ with suppress (Exception ):
140
+ options ._session .quit ()
138
141
except AttributeError :
139
142
pass
140
143
options ._session = self
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ async def start(
37
37
Helper function to launch a browser. It accepts several keyword parameters.
38
38
Conveniently, you can just call it bare (no parameters) to quickly launch
39
39
an instance with best practice defaults.
40
+ Note: Due to a Chrome-130 bug, use start_async or start_sync instead.
41
+ (Calling this method directly could lead to an unresponsive browser)
40
42
Note: New args are expected: Use kwargs only!
41
43
Note: This should be called ``await start()``
42
44
:param user_data_dir:
@@ -88,6 +90,20 @@ async def start(
88
90
return await Browser .create (config )
89
91
90
92
93
+ async def start_async (* args , ** kwargs ) -> Browser :
94
+ headless = False
95
+ if "headless" in kwargs :
96
+ headless = kwargs ["headless" ]
97
+ decoy_args = kwargs
98
+ decoy_args ["headless" ] = True
99
+ driver = await start (** decoy_args )
100
+ kwargs ["headless" ] = headless
101
+ kwargs ["user_data_dir" ] = driver .config .user_data_dir
102
+ driver .stop () # Due to Chrome-130, must stop & start
103
+ time .sleep (0.15 )
104
+ return await start (* args , ** kwargs )
105
+
106
+
91
107
def start_sync (* args , ** kwargs ) -> Browser :
92
108
loop = asyncio .get_event_loop ()
93
109
headless = False
You can’t perform that action at this time.
0 commit comments