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 15, 2022
1 parent 19e5890 commit b37c535
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Driver/CoreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,23 @@ public function dragTo($sourceXpath, $destinationXpath)
/**
* {@inheritdoc}
*/
public function executeScript($script)
public function executeScript($script, array $args = [])
{
throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
}

/**
* {@inheritdoc}
*/
public function evaluateScript($script)
public function evaluateScript($script, array $args = [])
{
throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
}

/**
* {@inheritdoc}
*/
public function wait($timeout, $condition)
public function wait($timeout, $condition, array $args = [])
{
throw new UnsupportedDriverActionException('JS is not supported by %s', $this);
}
Expand Down
9 changes: 6 additions & 3 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, array $args = []);

/**
* Evaluates JS script.
Expand All @@ -582,26 +583,28 @@ 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, array $args = []);

/**
* Waits some time or until JS condition turns true.
*
* @param int $timeout timeout in milliseconds
* @param string $condition JS condition
* @param array $args
*
* @return bool
*
* @throws UnsupportedDriverActionException When operation not supported by the driver
* @throws DriverException When the operation cannot be done
*/
public function wait($timeout, $condition);
public function wait($timeout, $condition, array $args = []);

/**
* Set the dimensions of the window.
Expand Down
15 changes: 9 additions & 6 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,35 +325,38 @@ public function switchToIFrame($name = null)
* Execute JS in browser.
*
* @param string $script javascript
* @param array $args
*/
public function executeScript($script)
public function executeScript($script, array $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, array $args = [])
{
return $this->driver->evaluateScript($script);
return $this->driver->evaluateScript($script, $args);
}

/**
* Waits some time or until JS condition turns true.
*
* @param int $time time in milliseconds
* @param string $condition JS condition
* @param array $args
*
* @return bool
*/
public function wait($time, $condition = 'false')
public function wait($time, $condition = 'false', array $args = [])
{
return $this->driver->wait($time, $condition);
return $this->driver->wait($time, $condition, $args);
}

/**
Expand Down

0 comments on commit b37c535

Please sign in to comment.