session = $session; $this->timeout = $timeout; $this->poll = $poll_frequency; $this->extra_arguments = $extra_arguments; return $this; } public function until($func) { $end_time = time() + $this->timeout; while(time() < $end_time) { try { $value = call_user_func($func, $this->session, $this->extra_arguments); if ($value) { return $value; } } catch (PHPWebDriver_NoSuchElementWebDriverError $e) { } usleep(intval($this->poll * 1000000)); } throw new PHPWebDriver_TimeOutWebDriverError( sprintf( 'Element wait timed out after %s', $this->timeout) . "\n\n"); } } ?>