goto method
The Page.goto will throw an error if:
- there's an SSL error (e.g. in case of self-signed certificates).
- target URL is invalid.
- the
timeout
is exceeded during navigation. - the main resource failed to load.
page.goto
will not throw an error when any valid HTTP status code is
returned by the remote server, including 404 "Not Found" and 500 "Internal Server Error".
The status code for such responses can be retrieved by calling response.status
.
NOTE
page.goto
either throws an error or returns a main resource response. The only exceptions are navigation toabout:blank
or navigation to the same URL with a different hash, which would succeed and returnnull
.
NOTE Headless mode doesn't support navigation to a PDF document. See the upstream issue.
Shortcut for Page.mainFrame.goto
Parameters:
url
: URL to navigate page to. The url should include scheme, e.g.https://
.timeout
Maximum navigation time in milliseconds, defaults to 30 seconds, pass Duration.zero to disable timeout. The default value can be changed by using the Page.defaultNavigationTimeout or Page.defaultTimeout properties.wait
When to consider navigation succeeded, defaults to Until.load. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:- Until.load - consider navigation to be finished when the
load
event is fired. - Until.domContentLoaded - consider navigation to be finished when the
DOMContentLoaded
event is fired. - Until.networkIdle - consider navigation to be finished when there
are no more than 0 network connections for at least
500
ms. - Until.networkAlmostIdle - consider navigation to be finished when
there are no more than 2 network connections for at least
500
ms.
- Until.load - consider navigation to be finished when the
referrer
Referer header value. If provided it will take preference over the referer header value set by Page.setExtraHTTPHeaders.
Returns: Future which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
Implementation
Future<Response> goto(String url,
{String? referrer, Duration? timeout, Until? wait}) {
return mainFrame.goto(url,
referrer: referrer, timeout: timeout, wait: wait);
}