Wait for the current page to reload.

@param  Closure  $callback
@param  int  $seconds
@return $this
@throws \Facebook\WebDriver\Exception\TimeOutException
354803
public function waitForReload($callback = null, $seconds = null)
    {
        $token = Str::random();

        $this->driver->executeScript("window['{$token}'] = {};");

        if ($callback) {
            $callback($this);
        }

        return $this->waitUsing($seconds, 100, function () use ($token) {
            return $this->driver->executeScript("return typeof window['{$token}'] === 'undefined';");
        }, 'Waited %s seconds for page reload.');
    }
1350566
function (fn) {
            if (domReady) {
                try {
                    fn(S);
                } catch (e) {
                    setTimeout(function () {
                        throw e;
                    }, 0);
                }
            } else {
                callbacks.push(fn);
            }
            return this;
        }
1355565
public function waitsFor($actual, $timeout = 0)
    {
        $timeout = $timeout ?: $this->timeout();
        $closure = $actual instanceof Closure ? $actual : function () use ($actual) {
            return $actual;
        };
        $spec = new static(['closure' => $closure]);

        return $this->expect($spec, $timeout);
    }
663971
public function setex($key, $seconds, $value) {
        return $this->returnCommand(['SETEX'], $key, [$key, $seconds, $value]);
    }
241446
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;
    }
797693
public function with($key, $callback, $seconds = 60)
    {
        if ($this->get($key, $seconds)) {
            try {
                call_user_func($callback);
            } finally {
                $this->release($key);
            }
        }
    }
53992
public function setCallback(Closure $callback = null)
    {
        if ($this->callback !== null || $callback === null) {
            throw new \RuntimeException("Cannot redeclare this comparer callback.");
        }

        $this->callback = Closure::bind($callback, $this, get_called_class());
    }
1017520
public function render(Closure $callback = null)
    {
        try {
            $contents = $this->renderContents();

            $response = isset($callback) ? $callback($this, $contents) : null;

            // Once we have the contents of the view, we will flush the sections if we are
            // done rendering all views so that there is nothing left hanging over when
            // another view gets rendered in the future by the application developer.
            $this->factory->flushSectionsIfDoneRendering();

            return $response ?: $contents;
        } catch (Exception $e) {
            $this->factory->flushSections();

            throw $e;
        }
    }
618738
public function missing(Closure $callback)
	{
		$this->error(function(NotFoundHttpException $e) use ($callback)
		{
			return call_user_func($callback, $e);
		});
	}
1010253
public function setTimeout($secondRequestTimeout=0.0)
    {
        if(!is_float($secondRequestTimeout)){
            $secondRequestTimeout = (float) 0.0;
        }

        $this->options['timeout']=(float) $secondRequestTimeout;
        return $this;
    }
373073
public function setClientTtl(int $seconds): self
    {
        $this->setMaxAge($this->getAge() + $seconds);

        return $this;
    }
926329
public function waitForRoute($route, $parameters = [], $seconds = null)
    {
        return $this->waitForLocation(route($route, $parameters, false), $seconds);
    }
453191
public function open(callable $callback)
    {
        $sessionHandleList = $this->getSessionWindowHandles();
        $callback($this->driver);
        for ($i = 0; $i < 10; $i++) {
            $handle = $this->getNewWindow($sessionHandleList);
            if ($handle === null) {
                sleep(1);
            } else {
                $this->setWindowHandle($handle);
                return $this;
            }
        }
        throw new WebDriver_Exception("The expected window didn't open.");
    }
1105216
public function remember($seconds, $key = null)
    {
        list($this->cacheSeconds, $this->cacheKey) = [$seconds, $key];

        return $this;
    }
1188149
public function getOnce($key, Closure $callback)
    {
        if ($this->has($key) !== false) {
            return $this->session[$key];
        } else {
            $value = $callback();
            $this->set($key, $value);
            return $value;
        }
    }
1211746
public function then(\Closure $callback)
    {
        if ($this->ready) {
            return null;
        }

        $this->ready = true;

        if (!$this->checkDomain() || !$this->checkPath() || !$this->checkSecurity()) {
            return null;
        }

        $oNS = parent::$prefixNS;
        $oPP = parent::$prefixPath;

        if ($this->ns) {
            parent::$prefixNS = $this->ns;
        }

        if ($this->path) {
            parent::$prefixPath = rtrim($this->currentPrefixPath, '/');
        }

        call_user_func_array($callback, $this->arguments);

        parent::$prefixNS = $oNS;
        parent::$prefixPath = $oPP;
    }
482676
public function maxAge($seconds)
    {
        $this->response = $this->corsHandler->setResponse($this->response)
            ->maxAge($seconds)
            ->getResponse();

        return $this;
    }