3333 cast ,
3434)
3535
36- from playwright ._impl ._accessibility import Accessibility
3736from playwright ._impl ._api_structures import (
3837 AriaRole ,
3938 FilePayload ,
@@ -150,7 +149,6 @@ class Page(ChannelOwner):
150149 WebSocket = "websocket" ,
151150 Worker = "worker" ,
152151 )
153- accessibility : Accessibility
154152 keyboard : Keyboard
155153 mouse : Mouse
156154 touchscreen : Touchscreen
@@ -160,7 +158,6 @@ def __init__(
160158 ) -> None :
161159 super ().__init__ (parent , type , guid , initializer )
162160 self ._browser_context = cast ("BrowserContext" , parent )
163- self .accessibility = Accessibility (self ._channel )
164161 self .keyboard = Keyboard (self ._channel )
165162 self .mouse = Mouse (self ._channel )
166163 self .touchscreen = Touchscreen (self ._channel )
@@ -854,7 +851,7 @@ async def click(
854851 trial : bool = None ,
855852 strict : bool = None ,
856853 ) -> None :
857- return await self ._main_frame .click (** locals_to_params (locals ()))
854+ return await self ._main_frame ._click (** locals_to_params (locals ()))
858855
859856 async def dblclick (
860857 self ,
@@ -1017,6 +1014,7 @@ async def drag_and_drop(
10171014 timeout : float = None ,
10181015 strict : bool = None ,
10191016 trial : bool = None ,
1017+ steps : int = None ,
10201018 ) -> None :
10211019 return await self ._main_frame .drag_and_drop (** locals_to_params (locals ()))
10221020
@@ -1452,12 +1450,13 @@ async def page_errors(self) -> List[Error]:
14521450
14531451
14541452class Worker (ChannelOwner ):
1455- Events = SimpleNamespace (Close = "close" )
1453+ Events = SimpleNamespace (Close = "close" , Console = "console" )
14561454
14571455 def __init__ (
14581456 self , parent : ChannelOwner , type : str , guid : str , initializer : Dict
14591457 ) -> None :
14601458 super ().__init__ (parent , type , guid , initializer )
1459+ self ._set_event_to_subscription_mapping ({Worker .Events .Console : "console" })
14611460 self ._channel .on ("close" , lambda _ : self ._on_close ())
14621461 self ._page : Optional [Page ] = None
14631462 self ._context : Optional ["BrowserContext" ] = None
@@ -1502,6 +1501,31 @@ async def evaluate_handle(
15021501 )
15031502 )
15041503
1504+ def expect_event (
1505+ self ,
1506+ event : str ,
1507+ predicate : Callable = None ,
1508+ timeout : float = None ,
1509+ ) -> EventContextManagerImpl :
1510+ if timeout is None :
1511+ if self ._page :
1512+ timeout = self ._page ._timeout_settings .timeout ()
1513+ elif self ._context :
1514+ timeout = self ._context ._timeout_settings .timeout ()
1515+ else :
1516+ timeout = 30000
1517+ waiter = Waiter (self , f"worker.expect_event({ event } )" )
1518+ waiter .reject_on_timeout (
1519+ cast (float , timeout ),
1520+ f'Timeout { timeout } ms exceeded while waiting for event "{ event } "' ,
1521+ )
1522+ if event != Worker .Events .Close :
1523+ waiter .reject_on_event (
1524+ self , Worker .Events .Close , lambda : TargetClosedError ()
1525+ )
1526+ waiter .wait_for_event (self , event , predicate )
1527+ return EventContextManagerImpl (waiter .result ())
1528+
15051529
15061530class BindingCall (ChannelOwner ):
15071531 def __init__ (
0 commit comments