|
@@ -1,8 +1,12 @@
|
|
|
+from typing import Optional
|
|
|
+
|
|
|
from .. import globals # pylint: disable=redefined-builtin
|
|
|
from ..awaitable_response import AwaitableResponse
|
|
|
|
|
|
|
|
|
-def run_javascript(code: str, *, timeout: float = 1.0, check_interval: float = 0.01) -> AwaitableResponse:
|
|
|
+def run_javascript(code: str, *,
|
|
|
+ respond: Optional[bool] = None, # DEPRECATED
|
|
|
+ timeout: float = 1.0, check_interval: float = 0.01) -> AwaitableResponse:
|
|
|
"""Run JavaScript
|
|
|
|
|
|
This function runs arbitrary JavaScript code on a page that is executed in the browser.
|
|
@@ -16,6 +20,15 @@ def run_javascript(code: str, *, timeout: float = 1.0, check_interval: float = 0
|
|
|
|
|
|
:return: response from the browser, or `None` if `respond` is `False`
|
|
|
"""
|
|
|
+ if respond is True:
|
|
|
+ globals.log.warning('The "respond" argument of run_javascript() has been removed. '
|
|
|
+ 'Now the function always returns an AwaitableResponse that can be awaited. '
|
|
|
+ 'Please remove the "respond=True" argument.')
|
|
|
+ if respond is False:
|
|
|
+ raise ValueError('The "respond" argument of run_javascript() has been removed. '
|
|
|
+ 'Now the function always returns an AwaitableResponse that can be awaited. '
|
|
|
+ 'Please remove the "respond=False" argument and call the function without awaiting.')
|
|
|
+
|
|
|
client = globals.get_client()
|
|
|
if not client.has_socket_connection:
|
|
|
raise RuntimeError('Cannot run JavaScript before client is connected; '
|