Click or drag to resize

ChromiumHostControlWaitForNavigationAsync Method

Version 109.1.110
This resolves when the browser navigates to a new URL or reloads. It is useful for when you run code which will indirectly cause the browser to navigate. A common use case would be when executing javascript that results in a navigation. e.g. clicks a link This must be called before executing the action that navigates the browser. It may not resolve correctly if called after.

Namespace:  CefSharp.WinForms.Host
Assembly:  CefSharp.WinForms (in CefSharp.WinForms.dll) Version: 109.1.110.0 (109.1.110.0)
Syntax
public Task<WaitForNavigationAsyncResponse> WaitForNavigationAsync(
	TimeSpan? timeout = null,
	CancellationToken cancellationToken = default
)

Parameters

timeout (Optional)
Type: SystemNullableTimeSpan
optional timeout, if not specified defaults to five(5) seconds.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
optional CancellationToken

Return Value

Type: TaskWaitForNavigationAsyncResponse
Task which resolves when LoadingStateChanged has been called with IsLoading false. or when LoadError is called to signify a load failure.

Implements

IChromiumWebBrowserBaseWaitForNavigationAsync(NullableTimeSpan, CancellationToken)
Remarks
Usage of the History APIhttps://developer.mozilla.org/en-US/docs/Web/API/History_API to change the URL is considered a navigation
Examples
string script = "document.getElementsByTagName('a')[0].click();";
await Task.WhenAll(
    chromiumWebBrowser.WaitForNavigationAsync(),
    chromiumWebBrowser.EvaluateScriptAsync(jsScript3));
See Also