trait JavascriptTrait in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/jcalderonzumba/mink-phantomjs-driver/src/JavascriptTrait.php \Zumba\Mink\Driver\JavascriptTrait
Class JavascriptTrait @package Zumba\Mink\Driver
Hierarchy
- trait \Zumba\Mink\Driver\JavascriptTrait
File
- vendor/
jcalderonzumba/ mink-phantomjs-driver/ src/ JavascriptTrait.php, line 11
Namespace
Zumba\Mink\DriverView source
trait JavascriptTrait {
/**
* Executes a script on the browser
* @param string $script
*/
public function executeScript($script) {
$this->browser
->execute($script);
}
/**
* Evaluates a script and returns the result
* @param string $script
* @return mixed
*/
public function evaluateScript($script) {
return $this->browser
->evaluate($script);
}
/**
* Waits some time or until JS condition turns true.
*
* @param integer $timeout timeout in milliseconds
* @param string $condition JS condition
* @return boolean
* @throws DriverException When the operation cannot be done
*/
public function wait($timeout, $condition) {
$start = microtime(true);
$end = $start + $timeout / 1000.0;
do {
$result = $this->browser
->evaluate($condition);
usleep(100000);
} while (microtime(true) < $end && !$result);
return (bool) $result;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JavascriptTrait:: |
public | function | Evaluates a script and returns the result | |
JavascriptTrait:: |
public | function | Executes a script on the browser | |
JavascriptTrait:: |
public | function | Waits some time or until JS condition turns true. |