diff --git a/src/Driver/DriverInterface.php b/src/Driver/DriverInterface.php index 0880960c7..1f37dc671 100644 --- a/src/Driver/DriverInterface.php +++ b/src/Driver/DriverInterface.php @@ -578,6 +578,12 @@ public function executeScript($script); * * The "return" keyword is optional in the script passed as argument. Driver implementations * must accept the expression both with and without the keyword. + * Multiline scripts must be wrapped in an immediately-invoked + * function expression. + * Examples of valid scripts: + * - '1 + 1' + * - 'return 1 + 1;' + * - '(function () {return 1 + 1;})()' * * @param string $script * diff --git a/src/Session.php b/src/Session.php index d8107724c..f087bbbae 100644 --- a/src/Session.php +++ b/src/Session.php @@ -332,6 +332,14 @@ public function executeScript($script) /** * Execute JS in browser and return it's response. * + * The "return" keyword is optional in the script passed as argument. + * Multiline scripts must be wrapped in an immediately-invoked + * function expression. + * Examples of valid scripts: + * - '1 + 1' + * - 'return 1 + 1;' + * - '(function () {return 1 + 1;})()' + * * @param string $script javascript * * @return string