15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
17
18
+
18
19
import warnings
19
- from typing import Optional
20
+ from typing import Any , Optional
20
21
21
22
from selenium .webdriver .common .bidi .common import command_builder
23
+ from selenium .webdriver .common .bidi .session import UserPromptHandler
22
24
from selenium .webdriver .common .proxy import Proxy
23
25
24
26
@@ -243,7 +245,7 @@ def y(self, value) -> None:
243
245
self ._y = value
244
246
245
247
@property
246
- def active (self ):
248
+ def active (self ) -> bool :
247
249
"""Gets the Window Status.
248
250
249
251
Returns:
@@ -269,6 +271,7 @@ def is_active(self) -> bool:
269
271
-------
270
272
bool: True if the client window is active, False otherwise.
271
273
"""
274
+ warnings .warn ("is_active method is deprecated, use `active` property instead" , DeprecationWarning , stacklevel = 2 )
272
275
return self .active
273
276
274
277
@classmethod
@@ -284,13 +287,13 @@ def from_dict(cls, data: dict) -> "ClientWindowInfo":
284
287
ClientWindowInfo: A new instance of ClientWindowInfo.
285
288
"""
286
289
return cls (
287
- client_window = data . get ( "clientWindow" ) ,
288
- state = data . get ( "state" ) ,
289
- width = data . get ( "width" ) ,
290
- height = data . get ( "height" ) ,
291
- x = data . get ( "x" ) ,
292
- y = data . get ( "y" ) ,
293
- active = data . get ( "active" ) ,
290
+ client_window = data [ "clientWindow" ] ,
291
+ state = data [ "state" ] ,
292
+ width = data [ "width" ] ,
293
+ height = data [ "height" ] ,
294
+ x = data [ "x" ] ,
295
+ y = data [ "y" ] ,
296
+ active = data [ "active" ] ,
294
297
)
295
298
296
299
@@ -300,26 +303,35 @@ class Browser:
300
303
def __init__ (self , conn ):
301
304
self .conn = conn
302
305
303
- def create_user_context (self , accept_insecure_certs : Optional [bool ] = None , proxy : Optional [Proxy ] = None ) -> str :
306
+ def create_user_context (
307
+ self ,
308
+ accept_insecure_certs : Optional [bool ] = None ,
309
+ proxy : Optional [Proxy ] = None ,
310
+ unhandled_prompt_behavior : Optional [UserPromptHandler ] = None ,
311
+ ) -> str :
304
312
"""Creates a new user context.
305
313
306
314
Parameters:
307
315
-----------
308
316
accept_insecure_certs: Optional flag to accept insecure TLS certificates
309
317
proxy: Optional proxy configuration for the user context
318
+ unhandled_prompt_behavior: Optional configuration for handling user prompts
310
319
311
320
Returns:
312
321
-------
313
322
str: The ID of the created user context.
314
323
"""
315
- params = {}
324
+ params : dict [ str , Any ] = {}
316
325
317
326
if accept_insecure_certs is not None :
318
327
params ["acceptInsecureCerts" ] = accept_insecure_certs
319
328
320
329
if proxy is not None :
321
330
params ["proxy" ] = proxy .to_bidi_dict ()
322
331
332
+ if unhandled_prompt_behavior is not None :
333
+ params ["unhandledPromptBehavior" ] = unhandled_prompt_behavior .to_dict ()
334
+
323
335
result = self .conn .execute (command_builder ("browser.createUserContext" , params ))
324
336
return result ["userContext" ]
325
337
0 commit comments