src/Concerns/WaitsForElements.php
public function waitUsing($seconds, $interval, Closure $callback, $message = null)
    {
        $seconds = is_null($seconds) ? static::$waitSeconds : $seconds;

        $this->pause($interval);

        $started = Carbon::now();

        while (true) {
            try {
                if ($callback()) {
                    break;
                }
            } catch (Exception $e) {
                //
            }

            if ($started->lt(Carbon::now()->subSeconds($seconds))) {
                throw new TimeOutException($message
                    ? sprintf($message, $seconds)
                    : "Waited {$seconds} seconds for callback."
                );
            }

            $this->pause($interval);
        }

        return $this;
    }
public function waitUsing($seconds, $interval, Closure $callback, $message = null)
    {
        $seconds = is_null($seconds) ? static::$waitSeconds : $seconds;

        $this->pause($interval);

        $started = Carbon::now();

        while (true) {
            try {
                if ($callback()) {
                    break;
                }
            } catch (Exception $e) {
                //
            }

            if ($started->lt(Carbon::now()->subSeconds($seconds))) {
                throw new TimeOutException($message
                    ? sprintf($message, $seconds)
                    : "Waited {$seconds} seconds for callback."
                );
            }

            $this->pause($interval);
        }

        return $this;
    }
public function waitUsing ( $ seconds , $ interval , Closure $ callback , $ message = null ) { $ seconds = is_null ( $ seconds ) ? static :: $ waitSeconds : $ seconds ; $ this -> pause ( $ interval ) ; $ started = Carbon :: now ( ) ; while ( true ) { try { if ( $ callback ( ) ) { break ; } } catch ( Exception $ e ) { // } if ( $ started -> lt ( Carbon :: now ( ) -> subSeconds ( $ seconds ) ) ) { throw new TimeOutException ( $ message ? sprintf ( $ message , $ seconds ) : "Waited {$seconds} seconds for callback." ) ; } $ this -> pause ( $ interval ) ; } return $ this ; }
Wait for the given callback to be true.

@param  int  $seconds
@param  int  $interval
@param  Closure  $callback
@param  string|null  $message
@return $this
@throws \Facebook\WebDriver\Exception\TimeOutException
Wait for the given callback to be true .