xref: /plugin/combo/vendor/php-webdriver/webdriver/lib/JavaScriptExecutor.php (revision 04fd306c7c155fa133ebb3669986875d65988276)
1*04fd306cSNickeau<?php
2*04fd306cSNickeau
3*04fd306cSNickeaunamespace Facebook\WebDriver;
4*04fd306cSNickeau
5*04fd306cSNickeau/**
6*04fd306cSNickeau * WebDriver interface implemented by drivers that support JavaScript.
7*04fd306cSNickeau */
8*04fd306cSNickeauinterface JavaScriptExecutor
9*04fd306cSNickeau{
10*04fd306cSNickeau    /**
11*04fd306cSNickeau     * Inject a snippet of JavaScript into the page for execution in the context
12*04fd306cSNickeau     * of the currently selected frame. The executed script is assumed to be
13*04fd306cSNickeau     * synchronous and the result of evaluating the script will be returned.
14*04fd306cSNickeau     *
15*04fd306cSNickeau     * @param string $script The script to inject.
16*04fd306cSNickeau     * @param array $arguments The arguments of the script.
17*04fd306cSNickeau     * @return mixed The return value of the script.
18*04fd306cSNickeau     */
19*04fd306cSNickeau    public function executeScript($script, array $arguments = []);
20*04fd306cSNickeau
21*04fd306cSNickeau    /**
22*04fd306cSNickeau     * Inject a snippet of JavaScript into the page for asynchronous execution in
23*04fd306cSNickeau     * the context of the currently selected frame.
24*04fd306cSNickeau     *
25*04fd306cSNickeau     * The driver will pass a callback as the last argument to the snippet, and
26*04fd306cSNickeau     * block until the callback is invoked.
27*04fd306cSNickeau     *
28*04fd306cSNickeau     * @see WebDriverExecuteAsyncScriptTestCase
29*04fd306cSNickeau     *
30*04fd306cSNickeau     * @param string $script The script to inject.
31*04fd306cSNickeau     * @param array $arguments The arguments of the script.
32*04fd306cSNickeau     * @return mixed The value passed by the script to the callback.
33*04fd306cSNickeau     */
34*04fd306cSNickeau    public function executeAsyncScript($script, array $arguments = []);
35*04fd306cSNickeau}
36