public function wait($timeout, $condition) {
    $start = microtime(true);
    $end = $start + $timeout / 1000.0;
    do {
      $result = $this->browser->evaluate($condition);
      if ($result) {
        // No need to wait any longer when the condition is met already.
        return TRUE;
      }
      usleep(100000);
    } while (microtime(true) < $end && !$result);

    return (bool)$result;
  }
public function wait($timeout, $condition) {
    $start = microtime(true);
    $end = $start + $timeout / 1000.0;
    do {
      $result = $this->browser->evaluate($condition);
      if ($result) {
        // No need to wait any longer when the condition is met already.
        return TRUE;
      }
      usleep(100000);
    } while (microtime(true) < $end && !$result);

    return (bool)$result;
  }
public function wait ( $ timeout , $ condition ) { $ start = microtime ( true ) ; $ end = $ start + $ timeout / 1000.0 ; do { $ result = $ this -> browser -> evaluate ( $ condition ) ; if ( $ result ) { // No need to wait any longer when the condition is met already. return TRUE ; } usleep ( 100000 ) ; } while ( microtime ( true ) < $ end && ! $ result ) ; return ( bool ) $ result ; }
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
Waits some time or until JS condition turns true .