Pinned scripts, script execution and console, error and DOM-mutation handlers. Returns: The session's ``Script`` object. Examples: `total = driver.script.execute("(a, b) => a + b", 1, 2)` `pinned = driver.script.pin("() => { window.helper = () =>
(self)
| 1313 | |
| 1314 | @property |
| 1315 | def script(self) -> Script: |
| 1316 | """Pinned scripts, script execution and console, error and DOM-mutation handlers. |
| 1317 | |
| 1318 | Returns: |
| 1319 | The session's ``Script`` object. |
| 1320 | |
| 1321 | Examples: |
| 1322 | `total = driver.script.execute("(a, b) => a + b", 1, 2)` |
| 1323 | `pinned = driver.script.pin("() => { window.helper = () => 42 }")` |
| 1324 | `handler_id = driver.script.add_console_handler(messages.append)` |
| 1325 | """ |
| 1326 | if not self._websocket_connection: |
| 1327 | self._start_bidi() |
| 1328 | |
| 1329 | if not self._script: |
| 1330 | self._script = Script(BidiScript(self._websocket_connection, self), self) |
| 1331 | |
| 1332 | return self._script |
| 1333 | |
| 1334 | def _start_bidi(self) -> None: |
| 1335 | if self.caps.get("webSocketUrl"): |
nothing calls this directly
no test coverage detected