Store a JavaScript script by a unique hashable ID for later execution. .. deprecated:: Use ``driver.script.pin()`` instead, which uses the WebDriver BiDi protocol. Example: `script = "return document.getElementById('foo').value"`
(self, script: str, script_key=None)
| 536 | return self.execute(Command.GET_TITLE).get("value", "") |
| 537 | |
| 538 | def pin_script(self, script: str, script_key=None) -> ScriptKey: |
| 539 | """Store a JavaScript script by a unique hashable ID for later execution. |
| 540 | |
| 541 | .. deprecated:: |
| 542 | Use ``driver.script.pin()`` instead, which uses the WebDriver BiDi protocol. |
| 543 | |
| 544 | Example: |
| 545 | `script = "return document.getElementById('foo').value"` |
| 546 | """ |
| 547 | warnings.warn( |
| 548 | "pin_script is deprecated, use driver.script.pin() instead", |
| 549 | DeprecationWarning, |
| 550 | stacklevel=2, |
| 551 | ) |
| 552 | script_key_instance = ScriptKey(script_key) |
| 553 | self.pinned_scripts[script_key_instance.id] = script |
| 554 | return script_key_instance |
| 555 | |
| 556 | def unpin(self, script_key: ScriptKey) -> None: |
| 557 | """Remove a pinned script from storage. |