You are here

public function JavascriptTrait::wait in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/jcalderonzumba/mink-phantomjs-driver/src/JavascriptTrait.php \Zumba\Mink\Driver\JavascriptTrait::wait()

Waits some time or until JS condition turns true.

Parameters

integer $timeout timeout in milliseconds:

string $condition JS condition:

Return value

boolean

Throws

DriverException When the operation cannot be done

File

vendor/jcalderonzumba/mink-phantomjs-driver/src/JavascriptTrait.php, line 38

Class

JavascriptTrait
Class JavascriptTrait @package Zumba\Mink\Driver

Namespace

Zumba\Mink\Driver

Code

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;
}