Class Page

Provides methods to interact with a single tab in Chromium. One IBrowser instance might have multiple IPage instances.

Inheritance
System.Object
Page
Implements
IPage
IDisposable
IAsyncDisposable
Namespace: PuppeteerSharp
Assembly: PuppeteerSharp.dll
Syntax
public class Page : object, IPage

Fields

| Request doc improvement View Source

SupportedMetrics

Declaration
public static readonly IEnumerable<string> SupportedMetrics
Field Value
Type Description
IEnumerable<System.String>

Properties

| Request doc improvement View Source

Accessibility

Gets the accessibility.

Declaration
public IAccessibility Accessibility { get; }
Property Value
Type Description
IAccessibility
| Request doc improvement View Source

Browser

Get the browser the page belongs to.

Declaration
public IBrowser Browser { get; }
Property Value
Type Description
IBrowser
| Request doc improvement View Source

BrowserContext

Get the browser context that the page belongs to.

Declaration
public IBrowserContext BrowserContext { get; }
Property Value
Type Description
IBrowserContext
| Request doc improvement View Source

Client

Declaration
public CDPSession Client { get; }
Property Value
Type Description
CDPSession
| Request doc improvement View Source

Coverage

Gets this page's coverage

Declaration
public ICoverage Coverage { get; }
Property Value
Type Description
ICoverage
| Request doc improvement View Source

DefaultNavigationTimeout

This setting will change the default maximum time for the following methods:

  • GoToAsync(String, NavigationOptions)
  • GoBackAsync(NavigationOptions)
  • GoForwardAsync(NavigationOptions)
  • ReloadAsync(NavigationOptions)
  • SetContentAsync(String, NavigationOptions)
  • WaitForNavigationAsync(NavigationOptions) NOTE DefaultNavigationTimeout takes priority over DefaultTimeout
Declaration
public int DefaultNavigationTimeout { get; set; }
Property Value
Type Description
System.Int32
| Request doc improvement View Source

DefaultTimeout

This setting will change the default maximum times for the following methods:

  • GoBackAsync(NavigationOptions)
  • GoForwardAsync(NavigationOptions)
  • GoToAsync(String, NavigationOptions)
  • ReloadAsync(NavigationOptions)
  • SetContentAsync(String, NavigationOptions)
  • WaitForFunctionAsync(String, Object[])
  • WaitForNavigationAsync(NavigationOptions)
  • WaitForRequestAsync(String, WaitForOptions)
  • WaitForResponseAsync(String, WaitForOptions)
  • WaitForXPathAsync(String, WaitForSelectorOptions)
  • WaitForSelectorAsync(String, WaitForSelectorOptions)
  • WaitForExpressionAsync(String, WaitForFunctionOptions)
Declaration
public int DefaultTimeout { get; set; }
Property Value
Type Description
System.Int32
| Request doc improvement View Source

Frames

Gets all frames attached to the page.

Declaration
public IFrame[] Frames { get; }
Property Value
Type Description
IFrame[]

An array of all frames attached to the page.

| Request doc improvement View Source

IsClosed

Get an indication that the page has been closed.

Declaration
public bool IsClosed { get; }
Property Value
Type Description
System.Boolean
| Request doc improvement View Source

IsDragInterceptionEnabled

true if drag events are being intercepted, false otherwise.

Declaration
public bool IsDragInterceptionEnabled { get; }
Property Value
Type Description
System.Boolean
| Request doc improvement View Source

Keyboard

Gets this page's keyboard

Declaration
public IKeyboard Keyboard { get; }
Property Value
Type Description
IKeyboard
| Request doc improvement View Source

MainFrame

Gets page's main frame

Declaration
public IFrame MainFrame { get; }
Property Value
Type Description
IFrame
Remarks

Page is guaranteed to have a main frame which persists during navigations.

| Request doc improvement View Source

Mouse

Gets this page's mouse

Declaration
public IMouse Mouse { get; }
Property Value
Type Description
IMouse
| Request doc improvement View Source

Target

Gets that target this page was created from.

Declaration
public ITarget Target { get; }
Property Value
Type Description
ITarget
| Request doc improvement View Source

Touchscreen

Gets this page's touchscreen

Declaration
public ITouchscreen Touchscreen { get; }
Property Value
Type Description
ITouchscreen
| Request doc improvement View Source

Tracing

Gets this page's tracing

Declaration
public ITracing Tracing { get; }
Property Value
Type Description
ITracing
| Request doc improvement View Source

Url

Shortcut for page.MainFrame.Url

Declaration
public string Url { get; }
Property Value
Type Description
System.String
| Request doc improvement View Source

Viewport

Gets this page's viewport

Declaration
public ViewPortOptions Viewport { get; }
Property Value
Type Description
ViewPortOptions
| Request doc improvement View Source

Workers

Gets all workers in the page.

Declaration
public Worker[] Workers { get; }
Property Value
Type Description
Worker[]

Methods

| Request doc improvement View Source

AddScriptTagAsync(AddTagOptions)

Adds a <script> tag into the page with the desired url or content

Declaration
public Task<IElementHandle> AddScriptTagAsync(AddTagOptions options)
Parameters
Type Name Description
AddTagOptions options

add script tag options

Returns
Type Description
Task<IElementHandle>

Task which resolves to the added tag when the script's onload fires or when the script content was injected into frame

Remarks

Shortcut for page.MainFrame.AddScriptTagAsync(options)

See Also
AddScriptTagAsync(AddTagOptions)
| Request doc improvement View Source

AddScriptTagAsync(String)

Adds a <script> tag into the page with the desired url or content

Declaration
public Task<IElementHandle> AddScriptTagAsync(string url)
Parameters
Type Name Description
System.String url

script url

Returns
Type Description
Task<IElementHandle>

Task which resolves to the added tag when the script's onload fires or when the script content was injected into frame

Remarks

Shortcut for page.MainFrame.AddScriptTagAsync(new AddTagOptions { Url = url })

| Request doc improvement View Source

AddStyleTagAsync(AddTagOptions)

Adds a <link rel="stylesheet"> tag into the page with the desired url or a <link rel="stylesheet"> tag with the content

Declaration
public Task<IElementHandle> AddStyleTagAsync(AddTagOptions options)
Parameters
Type Name Description
AddTagOptions options

add style tag options

Returns
Type Description
Task<IElementHandle>

Task which resolves to the added tag when the stylesheet's onload fires or when the CSS content was injected into frame

Remarks

Shortcut for page.MainFrame.AddStyleTagAsync(options)

See Also
AddStyleTagAsync(AddTagOptions)
| Request doc improvement View Source

AddStyleTagAsync(String)

Adds a <link rel="stylesheet"> tag into the page with the desired url or a <link rel="stylesheet"> tag with the content

Declaration
public Task<IElementHandle> AddStyleTagAsync(string url)
Parameters
Type Name Description
System.String url

stylesheel url

Returns
Type Description
Task<IElementHandle>

Task which resolves to the added tag when the stylesheet's onload fires or when the CSS content was injected into frame

Remarks

Shortcut for page.MainFrame.AddStyleTagAsync(new AddTagOptions { Url = url })

| Request doc improvement View Source

AuthenticateAsync(Credentials)

Provide credentials for http authentication https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication

Declaration
public Task AuthenticateAsync(Credentials credentials)
Parameters
Type Name Description
Credentials credentials

The credentials

Returns
Type Description
Task

A Task which resolves after the message is sent to the browser

Remarks

To disable authentication, pass null

| Request doc improvement View Source

BringToFrontAsync()

Brings page to front (activates tab).

Declaration
public Task BringToFrontAsync()
Returns
Type Description
Task

A task that resolves when the message has been sent to Chromium.

| Request doc improvement View Source

ClickAsync(String, ClickOptions)

Fetches an element with selector, scrolls it into view if needed, and then uses Mouse to click in the center of the element.

Declaration
public Task ClickAsync(string selector, ClickOptions options = null)
Parameters
Type Name Description
System.String selector

A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.

ClickOptions options

click options

Returns
Type Description
Task

Task which resolves when the element matching selector is successfully clicked

Exceptions
Type Condition
SelectorException

If there's no element matching selector

| Request doc improvement View Source

CloseAsync(PageCloseOptions)

Closes the page.

Declaration
public Task CloseAsync(PageCloseOptions options = null)
Parameters
Type Name Description
PageCloseOptions options

Close options.

Returns
Type Description
Task

Task.

| Request doc improvement View Source

DeleteCookieAsync(CookieParam[])

Deletes cookies from the page

Declaration
public async Task DeleteCookieAsync(params CookieParam[] cookies)
Parameters
Type Name Description
CookieParam[] cookies

Cookies to delete

Returns
Type Description
Task

Task

| Request doc improvement View Source

Dispose()

Declaration
public void Dispose()
| Request doc improvement View Source

Dispose(Boolean)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing
| Request doc improvement View Source

DisposeAsync()

Declaration
public ValueTask DisposeAsync()
Returns
Type Description
ValueTask
| Request doc improvement View Source

EmulateAsync(DeviceDescriptor)

Emulates given device metrics and user agent.

Declaration
public Task EmulateAsync(DeviceDescriptor options)
Parameters
Type Name Description
DeviceDescriptor options

Emulation options.

Returns
Type Description
Task

Task.

Remarks

This method is a shortcut for calling two methods: SetViewportAsync(ViewPortOptions) SetUserAgentAsync(String, UserAgentMetadata) To aid emulation, puppeteer provides a list of device descriptors which can be obtained via the Devices. EmulateAsync(DeviceDescriptor) will resize the page. A lot of websites don't expect phones to change size, so you should emulate before navigating to the page.

| Request doc improvement View Source

EmulateCPUThrottlingAsync(Nullable<Decimal>)

Enables CPU throttling to emulate slow CPUs.

Declaration
public Task EmulateCPUThrottlingAsync(decimal? factor = null)
Parameters
Type Name Description
System.Nullable<System.Decimal> factor

Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).

Returns
Type Description
Task

A task that resolves when the message has been sent to the browser.

| Request doc improvement View Source

EmulateIdleStateAsync(EmulateIdleOverrides)

Emulates the idle state. If no arguments set, clears idle state emulation.

Declaration
public async Task EmulateIdleStateAsync(EmulateIdleOverrides overrides = null)
Parameters
Type Name Description
EmulateIdleOverrides overrides
Returns
Type Description
Task

A task that resolves when the message has been sent to the browser.

| Request doc improvement View Source

EmulateMediaFeaturesAsync(IEnumerable<MediaFeatureValue>)

Given an array of media feature objects, emulates CSS media features on the page.

Declaration
public Task EmulateMediaFeaturesAsync(IEnumerable<MediaFeatureValue> features)
Parameters
Type Name Description
IEnumerable<MediaFeatureValue> features

Features to apply

Returns
Type Description
Task

Emulate features task

| Request doc improvement View Source

EmulateMediaTypeAsync(MediaType)

Emulates a media such as screen or print.

Declaration
public Task EmulateMediaTypeAsync(MediaType type)
Parameters
Type Name Description
MediaType type

Media to set.

Returns
Type Description
Task

Emulate media type task.

| Request doc improvement View Source

EmulateNetworkConditionsAsync(NetworkConditions)

Emulates network conditions

Declaration
public Task EmulateNetworkConditionsAsync(NetworkConditions networkConditions)
Parameters
Type Name Description
NetworkConditions networkConditions

Passing null disables network condition emulation.

Returns
Type Description
Task

Result task

Remarks

NOTE This does not affect WebSockets and WebRTC PeerConnections (see https://crbug.com/563644)

| Request doc improvement View Source

EmulateTimezoneAsync(String)

Changes the timezone of the page.

Declaration
public async Task EmulateTimezoneAsync(string timezoneId)
Parameters
Type Name Description
System.String timezoneId

Timezone to set. See ICU’s metaZones.txt for a list of supported timezone IDs. Passing null disables timezone emulation.

Returns
Type Description
Task

The viewport task.

| Request doc improvement View Source

EmulateVisionDeficiencyAsync(VisionDeficiency)

Simulates the given vision deficiency on the page.

Declaration
public Task EmulateVisionDeficiencyAsync(VisionDeficiency type)
Parameters
Type Name Description
VisionDeficiency type

The type of deficiency to simulate, or None to reset.

Returns
Type Description
Task

A task that resolves when the message has been sent to the browser.

| Request doc improvement View Source

EvaluateExpressionAsync(String)

Executes a script in browser context

Declaration
public Task<JToken> EvaluateExpressionAsync(string script)
Parameters
Type Name Description
System.String script

Script to be evaluated in browser context

Returns
Type Description
Task<JToken>

Task which resolves to script return value

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

See Also
https://www.newtonsoft.com/json/help/html/t_newtonsoft_json_linq_jtoken.htm
EvaluateFunctionAsync<T>(System.String, System.Object[])
| Request doc improvement View Source

EvaluateExpressionAsync<T>(String)

Executes a script in browser context

Declaration
public Task<T> EvaluateExpressionAsync<T>(string script)
Parameters
Type Name Description
System.String script

Script to be evaluated in browser context

Returns
Type Description
Task<T>

Task which resolves to script return value

Type Parameters
Name Description
T

The type to deserialize the result to

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

See Also
EvaluateFunctionAsync<T>(System.String, System.Object[])
| Request doc improvement View Source

EvaluateExpressionHandleAsync(String)

Executes a script in browser context

Declaration
public async Task<IJSHandle> EvaluateExpressionHandleAsync(string script)
Parameters
Type Name Description
System.String script

Script to be evaluated in browser context

Returns
Type Description
Task<IJSHandle>

Task which resolves to script return value

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

| Request doc improvement View Source

EvaluateExpressionOnNewDocumentAsync(String)

Adds a function which would be invoked in one of the following scenarios:

  • whenever the page is navigated
  • whenever the child frame is attached or navigated. In this case, the function is invoked in the context of the newly attached frame
Declaration
public Task EvaluateExpressionOnNewDocumentAsync(string expression)
Parameters
Type Name Description
System.String expression

Javascript expression to be evaluated in browser context

Returns
Type Description
Task

Task

Remarks

The function is invoked after the document was created but before any of its scripts were run. This is useful to amend JavaScript environment, e.g. to seed Math.random.

| Request doc improvement View Source

EvaluateFunctionAsync(String, Object[])

Executes a function in browser context

Declaration
public Task<JToken> EvaluateFunctionAsync(string script, params object[] args)
Parameters
Type Name Description
System.String script

Script to be evaluated in browser context

System.Object[] args

Arguments to pass to script

Returns
Type Description
Task<JToken>

Task which resolves to script return value

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value. IJSHandle instances can be passed as arguments

See Also
EvaluateExpressionAsync<T>(System.String)
| Request doc improvement View Source

EvaluateFunctionAsync<T>(String, Object[])

Executes a function in browser context

Declaration
public Task<T> EvaluateFunctionAsync<T>(string script, params object[] args)
Parameters
Type Name Description
System.String script

Script to be evaluated in browser context

System.Object[] args

Arguments to pass to script

Returns
Type Description
Task<T>

Task which resolves to script return value

Type Parameters
Name Description
T

The type to deserialize the result to

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value. IJSHandle instances can be passed as arguments

See Also
EvaluateExpressionAsync<T>(System.String)
| Request doc improvement View Source

EvaluateFunctionHandleAsync(String, Object[])

Executes a script in browser context

Declaration
public async Task<IJSHandle> EvaluateFunctionHandleAsync(string pageFunction, params object[] args)
Parameters
Type Name Description
System.String pageFunction

Script to be evaluated in browser context

System.Object[] args

Function arguments

Returns
Type Description
Task<IJSHandle>

Task which resolves to script return value

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value. IJSHandle instances can be passed as arguments

| Request doc improvement View Source

EvaluateFunctionOnNewDocumentAsync(String, Object[])

Adds a function which would be invoked in one of the following scenarios:

  • whenever the page is navigated
  • whenever the child frame is attached or navigated. In this case, the function is invoked in the context of the newly attached frame
Declaration
public Task EvaluateFunctionOnNewDocumentAsync(string pageFunction, params object[] args)
Parameters
Type Name Description
System.String pageFunction

Function to be evaluated in browser context

System.Object[] args

Arguments to pass to pageFunction

Returns
Type Description
Task

Task

Remarks

The function is invoked after the document was created but before any of its scripts were run. This is useful to amend JavaScript environment, e.g. to seed Math.random.

| Request doc improvement View Source

ExposeFunctionAsync(String, Action)

Adds a function called name on the page's window object. When called, the function executes puppeteerFunction in C# and returns a which resolves when puppeteerFunction completes.

Declaration
public Task ExposeFunctionAsync(string name, Action puppeteerFunction)
Parameters
Type Name Description
System.String name

Name of the function on the window object

Action puppeteerFunction

Callback function which will be called in Puppeteer's context.

Returns
Type Description
Task

Task

Remarks

If the puppeteerFunction returns a , it will be awaited. Functions installed via ExposeFunctionAsync(String, Action) survive navigations

| Request doc improvement View Source

ExposeFunctionAsync<TResult>(String, Func<TResult>)

Adds a function called name on the page's window object. When called, the function executes puppeteerFunction in C# and returns a which resolves to the return value of puppeteerFunction.

Declaration
public Task ExposeFunctionAsync<TResult>(string name, Func<TResult> puppeteerFunction)
Parameters
Type Name Description
System.String name

Name of the function on the window object

Func<TResult> puppeteerFunction

Callback function which will be called in Puppeteer's context.

Returns
Type Description
Task

Task

Type Parameters
Name Description
TResult

The result of puppeteerFunction

Remarks

If the puppeteerFunction returns a , it will be awaited. Functions installed via ExposeFunctionAsync<TResult>(String, Func<TResult>) survive navigations

| Request doc improvement View Source

ExposeFunctionAsync<T, TResult>(String, Func<T, TResult>)

Adds a function called name on the page's window object. When called, the function executes puppeteerFunction in C# and returns a which resolves to the return value of puppeteerFunction.

Declaration
public Task ExposeFunctionAsync<T, TResult>(string name, Func<T, TResult> puppeteerFunction)
Parameters
Type Name Description
System.String name

Name of the function on the window object

Func<T, TResult> puppeteerFunction

Callback function which will be called in Puppeteer's context.

Returns
Type Description
Task

Task

Type Parameters
Name Description
T

The parameter of puppeteerFunction

TResult

The result of puppeteerFunction

Remarks

If the puppeteerFunction returns a , it will be awaited. Functions installed via ExposeFunctionAsync<T, TResult>(String, Func<T, TResult>) survive navigations

| Request doc improvement View Source

ExposeFunctionAsync<T1, T2, TResult>(String, Func<T1, T2, TResult>)

Adds a function called name on the page's window object. When called, the function executes puppeteerFunction in C# and returns a which resolves to the return value of puppeteerFunction.

Declaration
public Task ExposeFunctionAsync<T1, T2, TResult>(string name, Func<T1, T2, TResult> puppeteerFunction)
Parameters
Type Name Description
System.String name

Name of the function on the window object

Func<T1, T2, TResult> puppeteerFunction

Callback function which will be called in Puppeteer's context.

Returns
Type Description
Task

Task

Type Parameters
Name Description
T1

The first parameter of puppeteerFunction

T2

The second parameter of puppeteerFunction

TResult

The result of puppeteerFunction

Remarks

If the puppeteerFunction returns a , it will be awaited. Functions installed via ExposeFunctionAsync<T1, T2, TResult>(String, Func<T1, T2, TResult>) survive navigations

| Request doc improvement View Source

ExposeFunctionAsync<T1, T2, T3, TResult>(String, Func<T1, T2, T3, TResult>)

Adds a function called name on the page's window object. When called, the function executes puppeteerFunction in C# and returns a which resolves to the return value of puppeteerFunction.

Declaration
public Task ExposeFunctionAsync<T1, T2, T3, TResult>(string name, Func<T1, T2, T3, TResult> puppeteerFunction)
Parameters
Type Name Description
System.String name

Name of the function on the window object

Func<T1, T2, T3, TResult> puppeteerFunction

Callback function which will be called in Puppeteer's context.

Returns
Type Description
Task

Task

Type Parameters
Name Description
T1

The first parameter of puppeteerFunction

T2

The second parameter of puppeteerFunction

T3

The third parameter of puppeteerFunction

TResult

The result of puppeteerFunction

Remarks

If the puppeteerFunction returns a , it will be awaited. Functions installed via ExposeFunctionAsync<T1, T2, T3, TResult>(String, Func<T1, T2, T3, TResult>) survive navigations

| Request doc improvement View Source

ExposeFunctionAsync<T1, T2, T3, T4, TResult>(String, Func<T1, T2, T3, T4, TResult>)

Adds a function called name on the page's window object. When called, the function executes puppeteerFunction in C# and returns a which resolves to the return value of puppeteerFunction.

Declaration
public Task ExposeFunctionAsync<T1, T2, T3, T4, TResult>(string name, Func<T1, T2, T3, T4, TResult> puppeteerFunction)
Parameters
Type Name Description
System.String name

Name of the function on the window object

Func<T1, T2, T3, T4, TResult> puppeteerFunction

Callback function which will be called in Puppeteer's context.

Returns
Type Description
Task

Task

Type Parameters
Name Description
T1

The first parameter of puppeteerFunction

T2

The second parameter of puppeteerFunction

T3

The third parameter of puppeteerFunction

T4

The fourth parameter of puppeteerFunction

TResult

The result of puppeteerFunction

Remarks

If the puppeteerFunction returns a , it will be awaited. Functions installed via ExposeFunctionAsync<T1, T2, T3, T4, TResult>(String, Func<T1, T2, T3, T4, TResult>) survive navigations

| Request doc improvement View Source

FocusAsync(String)

Fetches an element with selector and focuses it

Declaration
public Task FocusAsync(string selector)
Parameters
Type Name Description
System.String selector

A selector to search for element to focus. If there are multiple elements satisfying the selector, the first will be focused.

Returns
Type Description
Task

Task which resolves when the element matching selector is successfully focused

Exceptions
Type Condition
SelectorException

If there's no element matching selector

| Request doc improvement View Source

GetContentAsync()

Gets the full HTML contents of the page, including the doctype.

Declaration
public Task<string> GetContentAsync()
Returns
Type Description
Task<System.String>

Task which resolves to the HTML content.

See Also
GetContentAsync()
| Request doc improvement View Source

GetCookiesAsync(String[])

Returns the page's cookies

Declaration
public async Task<CookieParam[]> GetCookiesAsync(params string[] urls)
Parameters
Type Name Description
System.String[] urls

Url's to return cookies for

Returns
Type Description
Task<CookieParam[]>

Array of cookies

Remarks

If no URLs are specified, this method returns cookies for the current page URL. If URLs are specified, only cookies for those URLs are returned.

| Request doc improvement View Source

GetTitleAsync()

Returns page's title

Declaration
public Task<string> GetTitleAsync()
Returns
Type Description
Task<System.String>

page's title

| Request doc improvement View Source

GoBackAsync(NavigationOptions)

Navigate to the previous page in history.

Declaration
public Task<IResponse> GoBackAsync(NavigationOptions options = null)
Parameters
Type Name Description
NavigationOptions options

Navigation parameters.

Returns
Type Description
Task<IResponse>

Task that resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. If can not go back, resolves to null.

| Request doc improvement View Source

GoForwardAsync(NavigationOptions)

Navigate to the next page in history.

Declaration
public Task<IResponse> GoForwardAsync(NavigationOptions options = null)
Parameters
Type Name Description
NavigationOptions options

Navigation parameters.

Returns
Type Description
Task<IResponse>

Task that resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. If can not go forward, resolves to null.

| Request doc improvement View Source

GoToAsync(String, NavigationOptions)

Navigates to an url

Declaration
public Task<IResponse> GoToAsync(string url, NavigationOptions options)
Parameters
Type Name Description
System.String url

URL to navigate page to. The url should include scheme, e.g. https://.

NavigationOptions options

Navigation parameters.

Returns
Type Description
Task<IResponse>

Task which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.

Remarks

GoToAsync(String, Nullable<Int32>, WaitUntilNavigation[]) 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 remote server does not respond or is unreachable.
  • the main resource failed to load.

GoToAsync(String, Nullable<Int32>, WaitUntilNavigation[]) 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 Status

NOTE GoToAsync(String, Nullable<Int32>, WaitUntilNavigation[]) either throws an error or returns a main resource response. The only exceptions are navigation to about:blank or navigation to the same URL with a different hash, which would succeed and return null.

NOTE Headless mode doesn't support navigation to a PDF document. See the upstream issue.

Shortcut for GoToAsync(String, Nullable<Int32>, WaitUntilNavigation[])

See Also
GoToAsync(System.String, System.Nullable<System.Int32>, WaitUntilNavigation[])
| Request doc improvement View Source

GoToAsync(String, WaitUntilNavigation)

Navigates to an url

Declaration
public Task<IResponse> GoToAsync(string url, WaitUntilNavigation waitUntil)
Parameters
Type Name Description
System.String url

URL to navigate page to. The url should include scheme, e.g. https://.

WaitUntilNavigation waitUntil

When to consider navigation succeeded.

Returns
Type Description
Task<IResponse>

Task which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect

See Also
GoToAsync(System.String, NavigationOptions)
| Request doc improvement View Source

GoToAsync(String, Nullable<Int32>, WaitUntilNavigation[])

Navigates to an url

Declaration
public Task<IResponse> GoToAsync(string url, int? timeout = null, WaitUntilNavigation[] waitUntil = null)
Parameters
Type Name Description
System.String url

URL to navigate page to. The url should include scheme, e.g. https://.

System.Nullable<System.Int32> timeout

Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.

WaitUntilNavigation[] waitUntil

When to consider navigation succeeded, defaults to Load. Given an array of WaitUntilNavigation, navigation is considered to be successful after all events have been fired

Returns
Type Description
Task<IResponse>

Task which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect

See Also
GoToAsync(System.String, NavigationOptions)
| Request doc improvement View Source

HoverAsync(String)

Fetches an element with selector, scrolls it into view if needed, and then uses Mouse to hover over the center of the element.

Declaration
public Task HoverAsync(string selector)
Parameters
Type Name Description
System.String selector

A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.

Returns
Type Description
Task

Task which resolves when the element matching selector is successfully hovered

Exceptions
Type Condition
SelectorException

If there's no element matching selector

| Request doc improvement View Source

MetricsAsync()

Returns metrics

Declaration
public async Task<Dictionary<string, decimal>> MetricsAsync()
Returns
Type Description
Task<Dictionary<System.String, System.Decimal>>

Task which resolves into a list of metrics

Remarks

All timestamps are in monotonic time: monotonically increasing time in seconds since an arbitrary point in the past.

| Request doc improvement View Source

PdfAsync(String)

generates a pdf of the page with Print css media. To generate a pdf with Screen media call EmulateMediaTypeAsync(MediaType) with Screen

Declaration
public Task PdfAsync(string file)
Parameters
Type Name Description
System.String file

The file path to save the PDF to. paths are resolved using

Returns
Type Description
Task

A Task which resolves after the PDF is generated

Remarks

Generating a pdf is currently only supported in Chrome headless

| Request doc improvement View Source

PdfAsync(String, PdfOptions)

generates a pdf of the page with Print css media. To generate a pdf with Screen media call EmulateMediaTypeAsync(MediaType) with Screen

Declaration
public async Task PdfAsync(string file, PdfOptions options)
Parameters
Type Name Description
System.String file

The file path to save the PDF to. paths are resolved using

PdfOptions options

pdf options

Returns
Type Description
Task

A Task which resolves after the PDF is generated

Remarks

Generating a pdf is currently only supported in Chrome headless

| Request doc improvement View Source

PdfDataAsync()

Generates a pdf of the page with Print css media. To generate a pdf with Screen media call EmulateMediaTypeAsync(MediaType) with Screen

Declaration
public Task<byte[]> PdfDataAsync()
Returns
Type Description
Task<System.Byte[]>

Task which resolves to a [] containing the PDF data.

Remarks

Generating a pdf is currently only supported in Chrome headless

| Request doc improvement View Source

PdfDataAsync(PdfOptions)

Generates a pdf of the page with Print css media. To generate a pdf with Screen media call EmulateMediaTypeAsync(MediaType) with Screen

Declaration
public Task<byte[]> PdfDataAsync(PdfOptions options)
Parameters
Type Name Description
PdfOptions options

pdf options

Returns
Type Description
Task<System.Byte[]>

Task which resolves to a [] containing the PDF data.

Remarks

Generating a pdf is currently only supported in Chrome headless

| Request doc improvement View Source

PdfStreamAsync()

generates a pdf of the page with Print css media. To generate a pdf with Screen media call EmulateMediaTypeAsync(MediaType) with Screen

Declaration
public Task<Stream> PdfStreamAsync()
Returns
Type Description
Task<Stream>

Task which resolves to a containing the PDF data.

Remarks

Generating a pdf is currently only supported in Chrome headless

| Request doc improvement View Source

PdfStreamAsync(PdfOptions)

Generates a pdf of the page with Print css media. To generate a pdf with Screen media call EmulateMediaTypeAsync(MediaType) with Screen

Declaration
public async Task<Stream> PdfStreamAsync(PdfOptions options)
Parameters
Type Name Description
PdfOptions options

pdf options

Returns
Type Description
Task<Stream>

Task which resolves to a containing the PDF data.

Remarks

Generating a pdf is currently only supported in Chrome headless

| Request doc improvement View Source

QueryObjectsAsync(IJSHandle)

The method iterates JavaScript heap and finds all the objects with the given prototype. Shortcut for page.MainFrame.GetExecutionContextAsync().QueryObjectsAsync(prototypeHandle).

Declaration
public async Task<IJSHandle> QueryObjectsAsync(IJSHandle prototypeHandle)
Parameters
Type Name Description
IJSHandle prototypeHandle

A handle to the object prototype.

Returns
Type Description
Task<IJSHandle>

A task which resolves to a handle to an array of objects with this prototype.

| Request doc improvement View Source

QuerySelectorAllAsync(String)

Runs document.querySelectorAll within the page. If no elements match the selector, the return value resolve to .

Declaration
public Task<IElementHandle[]> QuerySelectorAllAsync(string selector)
Parameters
Type Name Description
System.String selector

A selector to query page for

Returns
Type Description
Task<IElementHandle[]>

Task which resolves to ElementHandles pointing to the frame elements

See Also
QuerySelectorAllAsync(System.String)
| Request doc improvement View Source

QuerySelectorAllHandleAsync(String)

A utility function to be used with EvaluateFunctionAsync<T>(Task<IJSHandle>, String, Object[])

Declaration
public Task<IJSHandle> QuerySelectorAllHandleAsync(string selector)
Parameters
Type Name Description
System.String selector

A selector to query page for

Returns
Type Description
Task<IJSHandle>

Task which resolves to a IJSHandle of document.querySelectorAll result

| Request doc improvement View Source

QuerySelectorAsync(String)

The method runs document.querySelector within the page. If no element matches the selector, the return value resolve to null.

Declaration
public Task<IElementHandle> QuerySelectorAsync(string selector)
Parameters
Type Name Description
System.String selector

A selector to query page for

Returns
Type Description
Task<IElementHandle>

Task which resolves to IElementHandle pointing to the frame element

Remarks

Shortcut for page.MainFrame.QuerySelectorAsync(selector)

See Also
QuerySelectorAsync(System.String)
| Request doc improvement View Source

ReloadAsync(NavigationOptions)

Reloads the page

Declaration
public async Task<IResponse> ReloadAsync(NavigationOptions options)
Parameters
Type Name Description
NavigationOptions options

Navigation options

Returns
Type Description
Task<IResponse>

Task which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect

See Also
ReloadAsync(System.Nullable<System.Int32>, WaitUntilNavigation[])
| Request doc improvement View Source

ReloadAsync(Nullable<Int32>, WaitUntilNavigation[])

Reloads the page

Declaration
public Task<IResponse> ReloadAsync(int? timeout = null, WaitUntilNavigation[] waitUntil = null)
Parameters
Type Name Description
System.Nullable<System.Int32> timeout

Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.

WaitUntilNavigation[] waitUntil

When to consider navigation succeeded, defaults to Load. Given an array of WaitUntilNavigation, navigation is considered to be successful after all events have been fired

Returns
Type Description
Task<IResponse>

Task which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect

See Also
ReloadAsync(NavigationOptions)
| Request doc improvement View Source

ScreenshotAsync(String)

Takes a screenshot of the page

Declaration
public Task ScreenshotAsync(string file)
Parameters
Type Name Description
System.String file

The file path to save the image to. The screenshot type will be inferred from file extension. If path is a relative path, then it is resolved relative to current working directory. If no path is provided, the image won't be saved to the disk.

Returns
Type Description
Task

The screenshot task.

| Request doc improvement View Source

ScreenshotAsync(String, ScreenshotOptions)

Takes a screenshot of the page

Declaration
public async Task ScreenshotAsync(string file, ScreenshotOptions options)
Parameters
Type Name Description
System.String file

The file path to save the image to. The screenshot type will be inferred from file extension. If path is a relative path, then it is resolved relative to current working directory. If no path is provided, the image won't be saved to the disk.

ScreenshotOptions options

Screenshot options.

Returns
Type Description
Task

The screenshot task.

| Request doc improvement View Source

ScreenshotBase64Async()

Takes a screenshot of the page

Declaration
public Task<string> ScreenshotBase64Async()
Returns
Type Description
Task<System.String>

Task which resolves to a containing the image data as base64.

| Request doc improvement View Source

ScreenshotBase64Async(ScreenshotOptions)

Takes a screenshot of the page

Declaration
public Task<string> ScreenshotBase64Async(ScreenshotOptions options)
Parameters
Type Name Description
ScreenshotOptions options

Screenshot options.

Returns
Type Description
Task<System.String>

Task which resolves to a containing the image data as base64.

| Request doc improvement View Source

ScreenshotDataAsync()

Takes a screenshot of the page

Declaration
public Task<byte[]> ScreenshotDataAsync()
Returns
Type Description
Task<System.Byte[]>

Task which resolves to a [] containing the image data.

| Request doc improvement View Source

ScreenshotDataAsync(ScreenshotOptions)

Takes a screenshot of the page

Declaration
public async Task<byte[]> ScreenshotDataAsync(ScreenshotOptions options)
Parameters
Type Name Description
ScreenshotOptions options

Screenshot options.

Returns
Type Description
Task<System.Byte[]>

Task which resolves to a [] containing the image data.

| Request doc improvement View Source

ScreenshotStreamAsync()

Takes a screenshot of the page

Declaration
public Task<Stream> ScreenshotStreamAsync()
Returns
Type Description
Task<Stream>

Task which resolves to a containing the image data.

| Request doc improvement View Source

ScreenshotStreamAsync(ScreenshotOptions)

Takes a screenshot of the page

Declaration
public async Task<Stream> ScreenshotStreamAsync(ScreenshotOptions options)
Parameters
Type Name Description
ScreenshotOptions options

Screenshot options.

Returns
Type Description
Task<Stream>

Task which resolves to a containing the image data.

| Request doc improvement View Source

SelectAsync(String, String[])

Triggers a change and input event once all the provided options have been selected. If there's no <select> element matching selector, the method throws an error.

Declaration
public Task<string[]> SelectAsync(string selector, params string[] values)
Parameters
Type Name Description
System.String selector

A selector to query page for

System.String[] values

Values of options to select. If the <select> has the multiple attribute, all values are considered, otherwise only the first one is taken into account.

Returns
Type Description
Task<System.String[]>

Returns an array of option values that have been successfully selected.

Exceptions
Type Condition
SelectorException

If there's no element matching selector

See Also
SelectAsync(System.String, System.String[])
| Request doc improvement View Source

SetBurstModeOffAsync()

Resets the background color and Viewport after taking Screenshots using BurstMode.

Declaration
public Task SetBurstModeOffAsync()
Returns
Type Description
Task

The burst mode off.

| Request doc improvement View Source

SetBypassCSPAsync(Boolean)

Toggles bypassing page's Content-Security-Policy.

Declaration
public Task SetBypassCSPAsync(bool enabled)
Parameters
Type Name Description
System.Boolean enabled

sets bypassing of page's Content-Security-Policy.

Returns
Type Description
Task

A Task which resolves after the message is sent to the browser

Remarks

CSP bypassing happens at the moment of CSP initialization rather then evaluation. Usually this means that SetBypassCSPAsync(Boolean) should be called before navigating to the domain.

| Request doc improvement View Source

SetCacheEnabledAsync(Boolean)

Toggles ignoring cache for each request based on the enabled state. By default, caching is enabled.

Declaration
public Task SetCacheEnabledAsync(bool enabled = true)
Parameters
Type Name Description
System.Boolean enabled

sets the enabled state of the cache

Returns
Type Description
Task

Task

| Request doc improvement View Source

SetContentAsync(String, NavigationOptions)

Sets the HTML markup to the page

Declaration
public Task SetContentAsync(string html, NavigationOptions options = null)
Parameters
Type Name Description
System.String html

HTML markup to assign to the page.

NavigationOptions options

The navigations options

Returns
Type Description
Task

Task.

See Also
SetContentAsync(System.String, NavigationOptions)
| Request doc improvement View Source

SetCookieAsync(CookieParam[])

Clears all of the current cookies and then sets the cookies for the page

Declaration
public async Task SetCookieAsync(params CookieParam[] cookies)
Parameters
Type Name Description
CookieParam[] cookies

Cookies to set

Returns
Type Description
Task

Task

| Request doc improvement View Source

SetDragInterceptionAsync(Boolean)

Whether to enable drag interception.

Declaration
public Task SetDragInterceptionAsync(bool enabled)
Parameters
Type Name Description
System.Boolean enabled

Interception enabled

Returns
Type Description
Task

A Task that resolves when the message was confirmed by the browser

Remarks

Activating drag interception enables the Input.drag, methods This provides the capability to capture drag events emitted on the page, which can then be used to simulate drag-and-drop.

| Request doc improvement View Source

SetExtraHttpHeadersAsync(Dictionary<String, String>)

Sets extra HTTP headers that will be sent with every request the page initiates

Declaration
public Task SetExtraHttpHeadersAsync(Dictionary<string, string> headers)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

Additional http headers to be sent with every request

Returns
Type Description
Task

Task

| Request doc improvement View Source

SetGeolocationAsync(GeolocationOption)

Sets the page's geolocation.

Declaration
public Task SetGeolocationAsync(GeolocationOption options)
Parameters
Type Name Description
GeolocationOption options

Geolocation options.

Returns
Type Description
Task

The task.

Remarks

Consider using OverridePermissionsAsync(String, IEnumerable<OverridePermission>) to grant permissions for the page to read its geolocation.

| Request doc improvement View Source

SetJavaScriptEnabledAsync(Boolean)

Enables/Disables Javascript on the page

Declaration
public Task SetJavaScriptEnabledAsync(bool enabled)
Parameters
Type Name Description
System.Boolean enabled

Whether or not to enable JavaScript on the page.

Returns
Type Description
Task

Task.

| Request doc improvement View Source

SetOfflineModeAsync(Boolean)

Set offline mode for the page.

Declaration
public Task SetOfflineModeAsync(bool value)
Parameters
Type Name Description
System.Boolean value

When true enables offline mode for the page.

Returns
Type Description
Task

Result task

| Request doc improvement View Source

SetRequestInterceptionAsync(Boolean)

Activating request interception enables request.AbortAsync, request.ContinueAsync and request.RespondAsync methods.

Declaration
public Task SetRequestInterceptionAsync(bool value)
Parameters
Type Name Description
System.Boolean value

Whether to enable request interception..

Returns
Type Description
Task

The request interception task.

| Request doc improvement View Source

SetUserAgentAsync(String, UserAgentMetadata)

Sets the user agent to be used in this page

Declaration
public Task SetUserAgentAsync(string userAgent, UserAgentMetadata userAgentData = null)
Parameters
Type Name Description
System.String userAgent

Specific user agent to use in this page

UserAgentMetadata userAgentData

Specific user agent client hint data to use in this page

Returns
Type Description
Task

Task

| Request doc improvement View Source

SetViewportAsync(ViewPortOptions)

Sets the viewport. In the case of multiple pages in a single browser, each page can have its own viewport size. SetViewportAsync(ViewPortOptions) will resize the page. A lot of websites don't expect phones to change size, so you should set the viewport before navigating to the page.

Declaration
public async Task SetViewportAsync(ViewPortOptions viewport)
Parameters
Type Name Description
ViewPortOptions viewport

Viewport options.

Returns
Type Description
Task

The viewport task.

| Request doc improvement View Source

TapAsync(String)

Fetches an element with selector, scrolls it into view if needed, and then uses Touchscreen to tap in the center of the element.

Declaration
public async Task TapAsync(string selector)
Parameters
Type Name Description
System.String selector

A selector to search for element to tap. If there are multiple elements satisfying the selector, the first will be clicked.

Returns
Type Description
Task

Task which resolves when the element matching selector is successfully tapped

Exceptions
Type Condition
SelectorException

If there's no element matching selector

| Request doc improvement View Source

TypeAsync(String, String, TypeOptions)

Sends a keydown, keypress/input, and keyup event for each character in the text.

Declaration
public Task TypeAsync(string selector, string text, TypeOptions options = null)
Parameters
Type Name Description
System.String selector

A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used.

System.String text

A text to type into a focused element

TypeOptions options

The options to apply to the type operation.

Returns
Type Description
Task

Task

Remarks

To press a special key, like Control or ArrowDown use PressAsync(String, PressOptions)

Exceptions
Type Condition
SelectorException

If there's no element matching selector

| Request doc improvement View Source

WaitForExpressionAsync(String, WaitForFunctionOptions)

Waits for an expression to be evaluated to a truthy value

Declaration
public Task<IJSHandle> WaitForExpressionAsync(string script, WaitForFunctionOptions options = null)
Parameters
Type Name Description
System.String script

Expression to be evaluated in browser context

WaitForFunctionOptions options

Optional waiting parameters

Returns
Type Description
Task<IJSHandle>

A task that resolves when the script returns a truthy value

See Also
WaitForExpressionAsync(System.String, WaitForFunctionOptions)
| Request doc improvement View Source

WaitForFileChooserAsync(WaitForFileChooserOptions)

Waits for a page to open a file picker

Declaration
public async Task<FileChooser> WaitForFileChooserAsync(WaitForFileChooserOptions options = null)
Parameters
Type Name Description
WaitForFileChooserOptions options

Optional waiting parameters.

Returns
Type Description
Task<FileChooser>

A task that resolves after a page requests a file picker.

Remarks

In non-headless Chromium, this method results in the native file picker dialog not showing up for the user.

| Request doc improvement View Source

WaitForFrameAsync(Func<IFrame, Boolean>, WaitForOptions)

Waits for a frame.

Declaration
public async Task<IFrame> WaitForFrameAsync(Func<IFrame, bool> predicate, WaitForOptions options = null)
Parameters
Type Name Description
Func<IFrame, System.Boolean> predicate

Function which looks for a matching frame.

WaitForOptions options

Options.

Returns
Type Description
Task<IFrame>

A task which resolves when a matching frame was attached to the page.

| Request doc improvement View Source

WaitForFrameAsync(String, WaitForOptions)

Waits for a frame.

Declaration
public Task<IFrame> WaitForFrameAsync(string url, WaitForOptions options = null)
Parameters
Type Name Description
System.String url

Frame url.

WaitForOptions options

Options.

Returns
Type Description
Task<IFrame>

A task which resolves when a matching frame was attached to the page.

| Request doc improvement View Source

WaitForFunctionAsync(String, WaitForFunctionOptions, Object[])

Waits for a function to be evaluated to a truthy value

Declaration
public Task<IJSHandle> WaitForFunctionAsync(string script, WaitForFunctionOptions options = null, params object[] args)
Parameters
Type Name Description
System.String script

Function to be evaluated in browser context

WaitForFunctionOptions options

Optional waiting parameters

System.Object[] args

Arguments to pass to script

Returns
Type Description
Task<IJSHandle>

A task that resolves when the script returns a truthy value

See Also
WaitForFunctionAsync(System.String, WaitForFunctionOptions, System.Object[])
| Request doc improvement View Source

WaitForFunctionAsync(String, Object[])

Waits for a function to be evaluated to a truthy value

Declaration
public Task<IJSHandle> WaitForFunctionAsync(string script, params object[] args)
Parameters
Type Name Description
System.String script

Function to be evaluated in browser context

System.Object[] args

Arguments to pass to script

Returns
Type Description
Task<IJSHandle>

A task that resolves when the script returns a truthy value

| Request doc improvement View Source

WaitForNavigationAsync(NavigationOptions)

This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly cause the page to navigate.

Declaration
public Task<IResponse> WaitForNavigationAsync(NavigationOptions options = null)
Parameters
Type Name Description
NavigationOptions options

navigation options

Returns
Type Description
Task<IResponse>

Task which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with null.

Remarks

Usage of the History API https://developer.mozilla.org/en-US/docs/Web/API/History_API to change the URL is considered a navigation

| Request doc improvement View Source

WaitForNetworkIdleAsync(WaitForNetworkIdleOptions)

Waits for Network Idle

Declaration
public async Task WaitForNetworkIdleAsync(WaitForNetworkIdleOptions options = null)
Parameters
Type Name Description
WaitForNetworkIdleOptions options

Optional waiting parameters

Returns
Type Description
Task

returns Task which resolves when network is idle

| Request doc improvement View Source

WaitForRequestAsync(Func<IRequest, Boolean>, WaitForOptions)

Waits for a request.

Declaration
public async Task<IRequest> WaitForRequestAsync(Func<IRequest, bool> predicate, WaitForOptions options = null)
Parameters
Type Name Description
Func<IRequest, System.Boolean> predicate

Function which looks for a matching request.

WaitForOptions options

Options.

Returns
Type Description
Task<IRequest>

A task which resolves when a matching request was made.

| Request doc improvement View Source

WaitForRequestAsync(String, WaitForOptions)

Waits for a request.

Declaration
public Task<IRequest> WaitForRequestAsync(string url, WaitForOptions options = null)
Parameters
Type Name Description
System.String url

URL to wait for.

WaitForOptions options

Options.

Returns
Type Description
Task<IRequest>

A task which resolves when a matching request was made.

| Request doc improvement View Source

WaitForResponseAsync(Func<IResponse, Boolean>, WaitForOptions)

Waits for a response.

Declaration
public Task<IResponse> WaitForResponseAsync(Func<IResponse, bool> predicate, WaitForOptions options = null)
Parameters
Type Name Description
Func<IResponse, System.Boolean> predicate

Function which looks for a matching response.

WaitForOptions options

Options.

Returns
Type Description
Task<IResponse>

A task which resolves when a matching response is received.

| Request doc improvement View Source

WaitForResponseAsync(Func<IResponse, Task<Boolean>>, WaitForOptions)

Waits for a response.

Declaration
public async Task<IResponse> WaitForResponseAsync(Func<IResponse, Task<bool>> predicate, WaitForOptions options = null)
Parameters
Type Name Description
Func<IResponse, Task<System.Boolean>> predicate

Function which looks for a matching response.

WaitForOptions options

Options.

Returns
Type Description
Task<IResponse>

A task which resolves when a matching response is received.

| Request doc improvement View Source

WaitForResponseAsync(String, WaitForOptions)

Waits for a response.

Declaration
public Task<IResponse> WaitForResponseAsync(string url, WaitForOptions options = null)
Parameters
Type Name Description
System.String url

URL to wait for.

WaitForOptions options

Options.

Returns
Type Description
Task<IResponse>

A task which resolves when a matching response is received.

| Request doc improvement View Source

WaitForSelectorAsync(String, WaitForSelectorOptions)

Waits for a selector to be added to the DOM

Declaration
public Task<IElementHandle> WaitForSelectorAsync(string selector, WaitForSelectorOptions options = null)
Parameters
Type Name Description
System.String selector

A selector of an element to wait for

WaitForSelectorOptions options

Optional waiting parameters

Returns
Type Description
Task<IElementHandle>

A task that resolves when element specified by selector string is added to DOM. Resolves to null if waiting for hidden: true and selector is not found in DOM.

See Also
WaitForXPathAsync(System.String, WaitForSelectorOptions)
WaitForSelectorAsync(System.String, WaitForSelectorOptions)
| Request doc improvement View Source

WaitForTimeoutAsync(Int32)

Waits for a timeout

Declaration
public Task WaitForTimeoutAsync(int milliseconds)
Parameters
Type Name Description
System.Int32 milliseconds

The amount of time to wait.

Returns
Type Description
Task

A task that resolves when after the timeout

See Also
WaitForTimeoutAsync(System.Int32)
| Request doc improvement View Source

WaitForXPathAsync(String, WaitForSelectorOptions)

Waits for a xpath selector to be added to the DOM

Declaration
public Task<IElementHandle> WaitForXPathAsync(string xpath, WaitForSelectorOptions options = null)
Parameters
Type Name Description
System.String xpath

A xpath selector of an element to wait for

WaitForSelectorOptions options

Optional waiting parameters

Returns
Type Description
Task<IElementHandle>

A task which resolves when element specified by xpath string is added to DOM. Resolves to null if waiting for hidden: true and xpath is not found in DOM.

See Also
WaitForSelectorAsync(System.String, WaitForSelectorOptions)
WaitForXPathAsync(System.String, WaitForSelectorOptions)
| Request doc improvement View Source

XPathAsync(String)

Evaluates the XPath expression

Declaration
public Task<IElementHandle[]> XPathAsync(string expression)
Parameters
Type Name Description
System.String expression

Expression to evaluate https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate

Returns
Type Description
Task<IElementHandle[]>

Task which resolves to an array of IElementHandle

Remarks

Shortcut for page.MainFrame.XPathAsync(expression)

See Also
XPathAsync(System.String)

Events

| Request doc improvement View Source

Close

Raised when the page closes.

Declaration
public event EventHandler Close
Event Type
Type Description
EventHandler
| Request doc improvement View Source

Console

Raised when JavaScript within the page calls one of console API methods, e.g. console.log or console.dir. Also emitted if the page throws an error or a warning. The arguments passed into console.log appear as arguments on the event handler.

Declaration
public event EventHandler<ConsoleEventArgs> Console
Event Type
Type Description
EventHandler<ConsoleEventArgs>
| Request doc improvement View Source

Dialog

Raised when a JavaScript dialog appears, such as alert, prompt, confirm or beforeunload. Puppeteer can respond to the dialog via Dialog's Accept(String) or Dismiss() methods.

Declaration
public event EventHandler<DialogEventArgs> Dialog
Event Type
Type Description
EventHandler<DialogEventArgs>
| Request doc improvement View Source

DOMContentLoaded

Raised when the JavaScript DOMContentLoaded https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded event is dispatched.

Declaration
public event EventHandler DOMContentLoaded
Event Type
Type Description
EventHandler
| Request doc improvement View Source

Error

Raised when the page crashes

Declaration
public event EventHandler<ErrorEventArgs> Error
Event Type
Type Description
EventHandler<ErrorEventArgs>
| Request doc improvement View Source

FrameAttached

Raised when a frame is attached.

Declaration
public event EventHandler<FrameEventArgs> FrameAttached
Event Type
Type Description
EventHandler<FrameEventArgs>
| Request doc improvement View Source

FrameDetached

Raised when a frame is detached.

Declaration
public event EventHandler<FrameEventArgs> FrameDetached
Event Type
Type Description
EventHandler<FrameEventArgs>
| Request doc improvement View Source

FrameNavigated

Raised when a frame is navigated to a new url.

Declaration
public event EventHandler<FrameEventArgs> FrameNavigated
Event Type
Type Description
EventHandler<FrameEventArgs>
| Request doc improvement View Source

Load

Raised when the JavaScript load https://developer.mozilla.org/en-US/docs/Web/Events/load event is dispatched.

Declaration
public event EventHandler Load
Event Type
Type Description
EventHandler
| Request doc improvement View Source

Metrics

Raised when the JavaScript code makes a call to console.timeStamp. For the list of metrics see MetricsAsync().

Declaration
public event EventHandler<MetricEventArgs> Metrics
Event Type
Type Description
EventHandler<MetricEventArgs>
| Request doc improvement View Source

PageError

Raised when an uncaught exception happens within the page.

Declaration
public event EventHandler<PageErrorEventArgs> PageError
Event Type
Type Description
EventHandler<PageErrorEventArgs>
| Request doc improvement View Source

Popup

Raised when the page opens a new tab or window.

Declaration
public event EventHandler<PopupEventArgs> Popup
Event Type
Type Description
EventHandler<PopupEventArgs>
| Request doc improvement View Source

Request

Raised when a page issues a request. The Request object is read-only. In order to intercept and mutate requests, see SetRequestInterceptionAsync(Boolean)

Declaration
public event EventHandler<RequestEventArgs> Request
Event Type
Type Description
EventHandler<RequestEventArgs>
| Request doc improvement View Source

RequestFailed

Raised when a request fails, for example by timing out.

Declaration
public event EventHandler<RequestEventArgs> RequestFailed
Event Type
Type Description
EventHandler<RequestEventArgs>
| Request doc improvement View Source

RequestFinished

Raised when a request finishes successfully.

Declaration
public event EventHandler<RequestEventArgs> RequestFinished
Event Type
Type Description
EventHandler<RequestEventArgs>
| Request doc improvement View Source

RequestServedFromCache

Raised when a request ended up loading from cache.

Declaration
public event EventHandler<RequestEventArgs> RequestServedFromCache
Event Type
Type Description
EventHandler<RequestEventArgs>
| Request doc improvement View Source

Response

Raised when a Response is received.

Declaration
public event EventHandler<ResponseCreatedEventArgs> Response
Event Type
Type Description
EventHandler<ResponseCreatedEventArgs>
| Request doc improvement View Source

WorkerCreated

Emitted when a dedicated WebWorker (https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the page.

Declaration
public event EventHandler<WorkerEventArgs> WorkerCreated
Event Type
Type Description
EventHandler<WorkerEventArgs>
| Request doc improvement View Source

WorkerDestroyed

Emitted when a dedicated WebWorker (https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is terminated.

Declaration
public event EventHandler<WorkerEventArgs> WorkerDestroyed
Event Type
Type Description
EventHandler<WorkerEventArgs>

Explicit Interface Implementations

| Request doc improvement View Source

IPage.Client

Declaration
ICDPSession IPage.Client { get; }
Returns
Type Description
ICDPSession

Implements

IPage
IDisposable
IAsyncDisposable
  • Request doc improvement
  • View Source
Generated by DocFX

www.hardkoded.com

Back to top