1515# specific language governing permissions and limitations
1616# under the License.
1717
18+
1819import warnings
19- from typing import Optional
20+ from typing import Any , Optional
2021
2122from selenium .webdriver .common .bidi .common import command_builder
23+ from selenium .webdriver .common .bidi .session import UserPromptHandler
2224from selenium .webdriver .common .proxy import Proxy
2325
2426
@@ -243,7 +245,7 @@ def y(self, value) -> None:
243245 self ._y = value
244246
245247 @property
246- def active (self ):
248+ def active (self ) -> bool :
247249 """Gets the Window Status.
248250
249251 Returns:
@@ -269,6 +271,7 @@ def is_active(self) -> bool:
269271 -------
270272 bool: True if the client window is active, False otherwise.
271273 """
274+ warnings .warn ("is_active method is deprecated, use `active` property instead" , DeprecationWarning , stacklevel = 2 )
272275 return self .active
273276
274277 @classmethod
@@ -284,13 +287,13 @@ def from_dict(cls, data: dict) -> "ClientWindowInfo":
284287 ClientWindowInfo: A new instance of ClientWindowInfo.
285288 """
286289 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" ] ,
294297 )
295298
296299
@@ -300,26 +303,35 @@ class Browser:
300303 def __init__ (self , conn ):
301304 self .conn = conn
302305
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 :
304312 """Creates a new user context.
305313
306314 Parameters:
307315 -----------
308316 accept_insecure_certs: Optional flag to accept insecure TLS certificates
309317 proxy: Optional proxy configuration for the user context
318+ unhandled_prompt_behavior: Optional configuration for handling user prompts
310319
311320 Returns:
312321 -------
313322 str: The ID of the created user context.
314323 """
315- params = {}
324+ params : dict [ str , Any ] = {}
316325
317326 if accept_insecure_certs is not None :
318327 params ["acceptInsecureCerts" ] = accept_insecure_certs
319328
320329 if proxy is not None :
321330 params ["proxy" ] = proxy .to_bidi_dict ()
322331
332+ if unhandled_prompt_behavior is not None :
333+ params ["unhandledPromptBehavior" ] = unhandled_prompt_behavior .to_dict ()
334+
323335 result = self .conn .execute (command_builder ("browser.createUserContext" , params ))
324336 return result ["userContext" ]
325337
0 commit comments