Skip to content

Commit

Permalink
Add support for execute args
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 14, 2022
1 parent 19e5890 commit f49f3a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Driver/CoreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,15 @@ public function dragTo($sourceXpath, $destinationXpath)
/**
* {@inheritdoc}
*/
public function executeScript($script)
public function executeScript($script, $args = [])
{
throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
}

/**
* {@inheritdoc}
*/
public function evaluateScript($script)
public function evaluateScript($script, $args = [])
{
throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,12 @@ public function dragTo($sourceXpath, $destinationXpath);
* Executes JS script.
*
* @param string $script
* @param array $args
*
* @throws UnsupportedDriverActionException When operation not supported by the driver
* @throws DriverException When the operation cannot be done
*/
public function executeScript($script);
public function executeScript($script, $args = []);

/**
* Evaluates JS script.
Expand All @@ -582,13 +583,14 @@ public function executeScript($script);
* must accept the expression both with and without the keyword.
*
* @param string $script
* @param array $args
*
* @return mixed
*
* @throws UnsupportedDriverActionException When operation not supported by the driver
* @throws DriverException When the operation cannot be done
*/
public function evaluateScript($script);
public function evaluateScript($script, $args = []);

/**
* Waits some time or until JS condition turns true.
Expand Down
10 changes: 6 additions & 4 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,24 @@ public function switchToIFrame($name = null)
* Execute JS in browser.
*
* @param string $script javascript
* @param array $args
*/
public function executeScript($script)
public function executeScript($script, $args = [])
{
$this->driver->executeScript($script);
$this->driver->executeScript($script, $args);
}

/**
* Execute JS in browser and return its response.
*
* @param string $script javascript
* @param array $args
*
* @return mixed
*/
public function evaluateScript($script)
public function evaluateScript($script, $args = [])
{
return $this->driver->evaluateScript($script);
return $this->driver->evaluateScript($script, $args);
}

/**
Expand Down

0 comments on commit f49f3a1

Please sign in to comment.