Synchronously Executes JavaScript in the current window/frame. Args: script: The javascript to execute. *args: Any applicable arguments for your JavaScript. Example: ``` id = "username" value = "test_user" driv
(self, script: str, *args)
| 654 | return list(self.pinned_scripts) |
| 655 | |
| 656 | def execute_script(self, script: str, *args) -> Any: |
| 657 | """Synchronously Executes JavaScript in the current window/frame. |
| 658 | |
| 659 | Args: |
| 660 | script: The javascript to execute. |
| 661 | *args: Any applicable arguments for your JavaScript. |
| 662 | |
| 663 | Example: |
| 664 | ``` |
| 665 | id = "username" |
| 666 | value = "test_user" |
| 667 | driver.execute_script("document.getElementById(arguments[0]).value = arguments[1];", id, value) |
| 668 | ``` |
| 669 | """ |
| 670 | if isinstance(script, ScriptKey): |
| 671 | script_id = script.id |
| 672 | try: |
| 673 | script = self.pinned_scripts[script_id] |
| 674 | except KeyError: |
| 675 | raise JavascriptException(f"Pinned script could not be found: {script_id}") from None |
| 676 | |
| 677 | converted_args = list(args) |
| 678 | command = Command.W3C_EXECUTE_SCRIPT |
| 679 | |
| 680 | return self.execute(command, {"script": script, "args": converted_args})["value"] |
| 681 | |
| 682 | def execute_async_script(self, script: str, *args) -> Any: |
| 683 | """Asynchronously Executes JavaScript in the current window/frame. |
no test coverage detected