JavaScriptExecutor.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // Copyright 2004-present Facebook. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. namespace Facebook\WebDriver;
  16. /**
  17. * WebDriver interface implemented by drivers that support JavaScript.
  18. */
  19. interface JavaScriptExecutor
  20. {
  21. /**
  22. * Inject a snippet of JavaScript into the page for execution in the context
  23. * of the currently selected frame. The executed script is assumed to be
  24. * synchronous and the result of evaluating the script will be returned.
  25. *
  26. * @param string $script The script to inject.
  27. * @param array $arguments The arguments of the script.
  28. * @return mixed The return value of the script.
  29. */
  30. public function executeScript($script, array $arguments = []);
  31. /**
  32. * Inject a snippet of JavaScript into the page for asynchronous execution in
  33. * the context of the currently selected frame.
  34. *
  35. * The driver will pass a callback as the last argument to the snippet, and
  36. * block until the callback is invoked.
  37. *
  38. * @see WebDriverExecuteAsyncScriptTestCase
  39. *
  40. * @param string $script The script to inject.
  41. * @param array $arguments The arguments of the script.
  42. * @return mixed The value passed by the script to the callback.
  43. */
  44. public function executeAsyncScript($script, array $arguments = []);
  45. }