WebBrowserExtensionsWaitForNavigationAsync Method |
Version 130.1.90
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: CefSharpAssembly: CefSharp (in CefSharp.dll) Version: 129.0.110.0 (129.0.110.0)
Syntax public static Task<WaitForNavigationAsyncResponse> WaitForNavigationAsync(
IChromiumWebBrowserBase chromiumWebBrowser,
TimeSpan? timeout = null,
CancellationToken cancellationToken = default
)
public:
static Task<WaitForNavigationAsyncResponse^>^ WaitForNavigationAsync(
IChromiumWebBrowserBase^ chromiumWebBrowser,
Nullable<TimeSpan> timeout = nullptr,
CancellationToken cancellationToken = CancellationToken()
)
Parameters
- chromiumWebBrowser IChromiumWebBrowserBase
- ChromiumWebBrowser instance (cannot be null)
- timeout NullableTimeSpan (Optional)
- optional timeout, if not specified defaults to five(5) seconds.
- cancellationToken CancellationToken (Optional)
- optional CancellationToken
Return Value
TaskWaitForNavigationAsyncResponseTask which resolves when
LoadingStateChanged has been called with
IsLoading false.
or when
LoadError is called to signify a load failure.
Remarks Example string script = "document.getElementsByTagName('a')[0].click();";
await Task.WhenAll(
chromiumWebBrowser.WaitForNavigationAsync(),
chromiumWebBrowser.EvaluateScriptAsync(script));
See Also