for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Zumba\Mink\Driver;
use Behat\Mink\Exception\DriverException;
/**
* Class JavascriptTrait
* @package Zumba\Mink\Driver
*/
trait JavascriptTrait {
* Executes a script on the browser
* @param string $script
public function executeScript($script) {
$this->browser->execute($script);
browser
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Evaluates a script and returns the result
* @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;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: