Best Python code snippet using playwright-python
chat_control.py
Source:chat_control.py
...316 def _on_audio(self, action, param):317 action.set_state(param)318 state = param.get_boolean()319 self.on_jingle_button_toggled(state, 'audio')320 def _on_video(self, action, param):321 action.set_state(param)322 state = param.get_boolean()323 self.on_jingle_button_toggled(state, 'video')324 def _on_send_chatstate(self, action, param):325 action.set_state(param)326 app.config.set_per('contacts', self.contact.jid,327 'send_chatstate', param.get_string())328 def subscribe_events(self):329 """330 Register listeners to the events class331 """332 app.events.event_added_subscribe(self.on_event_added)333 app.events.event_removed_subscribe(self.on_event_removed)334 def unsubscribe_events(self):...
_page.py
Source:_page.py
...187 lambda params: self._on_route(188 from_channel(params["route"]), from_channel(params["request"])189 ),190 )191 self._channel.on("video", lambda params: self._on_video(params))192 self._channel.on(193 "webSocket",194 lambda params: self.emit(195 Page.Events.WebSocket, from_channel(params["webSocket"])196 ),197 )198 self._channel.on(199 "worker", lambda params: self._on_worker(from_channel(params["worker"]))200 )201 self._closed_or_crashed_future: asyncio.Future = asyncio.Future()202 self.on(203 Page.Events.Close,204 lambda _: self._closed_or_crashed_future.set_result(True)205 if not self._closed_or_crashed_future.done()206 else None,207 )208 self.on(209 Page.Events.Crash,210 lambda _: self._closed_or_crashed_future.set_result(True)211 if not self._closed_or_crashed_future.done()212 else None,213 )214 def __repr__(self) -> str:215 return f"<Page url={self.url!r}>"216 def _on_frame_attached(self, frame: Frame) -> None:217 frame._page = self218 self._frames.append(frame)219 self.emit(Page.Events.FrameAttached, frame)220 def _on_frame_detached(self, frame: Frame) -> None:221 self._frames.remove(frame)222 frame._detached = True223 self.emit(Page.Events.FrameDetached, frame)224 def _on_route(self, route: Route, request: Request) -> None:225 for handler_entry in self._routes:226 if handler_entry.matches(request.url):227 try:228 handler_entry.handle(route, request)229 finally:230 if not handler_entry.is_active:231 self._routes.remove(handler_entry)232 if len(self._routes) == 0:233 asyncio.create_task(self._disable_interception())234 return235 self._browser_context._on_route(route, request)236 def _on_binding(self, binding_call: "BindingCall") -> None:237 func = self._bindings.get(binding_call._initializer["name"])238 if func:239 asyncio.create_task(binding_call.call(func))240 self._browser_context._on_binding(binding_call)241 def _on_worker(self, worker: "Worker") -> None:242 self._workers.append(worker)243 worker._page = self244 self.emit(Page.Events.Worker, worker)245 def _on_close(self) -> None:246 self._is_closed = True247 if self in self._browser_context._pages:248 self._browser_context._pages.remove(self)249 if self in self._browser_context._background_pages:250 self._browser_context._background_pages.remove(self)251 self.emit(Page.Events.Close, self)252 def _on_crash(self) -> None:253 self.emit(Page.Events.Crash, self)254 def _on_dialog(self, params: Any) -> None:255 dialog = cast(Dialog, from_channel(params["dialog"]))256 if self.listeners(Page.Events.Dialog):257 self.emit(Page.Events.Dialog, dialog)258 else:259 if dialog.type == "beforeunload":260 asyncio.create_task(dialog.accept())261 else:262 asyncio.create_task(dialog.dismiss())263 def _on_download(self, params: Any) -> None:264 url = params["url"]265 suggested_filename = params["suggestedFilename"]266 artifact = cast(Artifact, from_channel(params["artifact"]))267 self.emit(268 Page.Events.Download, Download(self, url, suggested_filename, artifact)269 )270 def _on_video(self, params: Any) -> None:271 artifact = from_channel(params["artifact"])272 cast(Video, self.video)._artifact_ready(artifact)273 def _add_event_handler(self, event: str, k: Any, v: Any) -> None:274 if event == Page.Events.FileChooser and len(self.listeners(event)) == 0:275 self._channel.send_no_reply(276 "setFileChooserInterceptedNoReply", {"intercepted": True}277 )278 super()._add_event_handler(event, k, v)279 def remove_listener(self, event: str, f: Any) -> None:280 super().remove_listener(event, f)281 if event == Page.Events.FileChooser and len(self.listeners(event)) == 0:282 self._channel.send_no_reply(283 "setFileChooserInterceptedNoReply", {"intercepted": False}284 )...
call_widget.py
Source:call_widget.py
...114 self._ui.jingle_audio_state.hide()115 self.set_no_show_all(True)116 self.hide()117 self.emit('call-ended')118 def _on_video(self, _button: Gtk.Button) -> None:119 self._on_jingle_button_toggled(['video'])120 def _on_jingle_button_toggled(self, jingle_types: list[str]) -> None:121 call_resources = self._get_call_resources()122 if not call_resources:123 return124 # TODO: Resource priority125 full_jid = call_resources[0].jid126 if all(item in jingle_types for item in ['audio', 'video']):127 # Both 'audio' and 'video' in jingle_types128 sid = self._client.get_module('Jingle').start_audio_video(full_jid)129 self._set_jingle_state('audio', JingleState.CONNECTING, sid)130 self._set_jingle_state('video', JingleState.CONNECTING, sid)131 self._store_outgoing_call(sid)132 return...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!