Returns the virtual keyboard.
Gets the virtual mouse.
Returns the virtual touchscreen object.
Returns the tracing object.
The method queries frame for the selector. If there's no such element within the frame, the method will resolve to null.
The method runs document.querySelectorAll within the frame. If no elements match the selector, the return value resolve to [].
This method runs Array.from(document.querySelectorAll(selector))
within the context and passes it as the
first argument to pageFunction
.
If pageFunction
returns a Promise, then $$eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
Promise which resolves to the return value of pageFunction
This method runs Array.from(document.querySelectorAll(selector))
within the context and passes it as the
first argument to pageFunction
.
If pageFunction
returns a Promise, then $$eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
First argument to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs Array.from(document.querySelectorAll(selector))
within the context and passes it as the
first argument to pageFunction
.
If pageFunction
returns a Promise, then $$eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
First argument to pass to pageFunction
Second argument to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs Array.from(document.querySelectorAll(selector))
within the context and passes it as the
first argument to pageFunction
.
If pageFunction
returns a Promise, then $$eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
First argument to pass to pageFunction
Second argument to pass to pageFunction
Third argument to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs Array.from(document.querySelectorAll(selector))
within the context and passes it as the
first argument to pageFunction
.
If pageFunction
returns a Promise, then $$eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
Arguments to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs document.querySelector
within the context and passes it as the first argument to pageFunction
.
If there's no element matching selector
, the method throws an error.
If pageFunction
returns a Promise, then $eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
Promise which resolves to the return value of pageFunction
This method runs document.querySelector
within the context and passes it as the first argument to pageFunction
.
If there's no element matching selector
, the method throws an error.
If pageFunction
returns a Promise, then $eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
First argument to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs document.querySelector
within the context and passes it as the first argument to pageFunction
.
If there's no element matching selector
, the method throws an error.
If pageFunction
returns a Promise, then $eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
First argument to pass to pageFunction
Second argument to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs document.querySelector
within the context and passes it as the first argument to pageFunction
.
If there's no element matching selector
, the method throws an error.
If pageFunction
returns a Promise, then $eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
First argument to pass to pageFunction
Second argument to pass to pageFunction
Third argument to pass to pageFunction
Promise which resolves to the return value of pageFunction
This method runs document.querySelector
within the context and passes it as the first argument to pageFunction
.
If there's no element matching selector
, the method throws an error.
If pageFunction
returns a Promise, then $eval
would wait for the promise to resolve and return its value.
A selector to query for
Function to be evaluated in browser context
Arguments to pass to pageFunction
Promise which resolves to the return value of pageFunction
The method evaluates the XPath expression.
XPath expression to evaluate.
Adds a <script>
tag into the page with the desired url or content.
Adds a <link rel="stylesheet">
tag into the page with the desired url or a <style type="text/css">
tag with the content.
Provide credentials for http authentication.
To disable authentication, pass null
.
Brings page to front (activates tab).
Get the browser the page belongs to.
Get the browser context that the page belongs to.
This method fetches an element with selector, scrolls it into view if needed, and
then uses page.mouse
to click in the center of the element. If there's no element
matching selector, the method throws an error.
A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.
Specifies the click options.
Closes the current page.
Gets the full HTML contents of the page, including the doctype.
Gets the cookies. 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.
Deletes the specified cookies.
Emulates given device metrics and user agent. This method is a shortcut for setUserAgent
and setViewport
.
Emulates the idle state. If no arguments set, clears idle state emulation.
Mock idle state. If not set, clears idle overrides
Given an array of media feature objects, emulates CSS media features on the page. Passing null resets all.
Emulates the media.
Changes the timezone of the page. See ICU’s metaZones.txt for a list of supported timezone IDs. Passing null disables timezone emulation.
Evaluates a function in the browser context. If the function, passed to the frame.evaluate, returns a Promise, then frame.evaluate would wait for the promise to resolve and return its value. If the function passed into frame.evaluate returns a non-Serializable value, then frame.evaluate resolves to undefined.
Arguments to pass to fn
The only difference between evaluate
and evaluateHandle
is that evaluateHandle
returns in-page object (JSHandle
).
If the function, passed to the evaluateHandle
, returns a Promise
, then evaluateHandle
would wait for the
promise to resolve and return its value.
The TypeScript definitions assume that evaluateHandle
returns a JSHandle
, but if you know it's going to return an
ElementHandle
, pass it as the generic argument:
a function that is run within the page
arguments to be passed to the pageFunction
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. 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.
The function to be evaluated in browser context.
The arguments to pass to the fn
.
The method adds a function called name on the page's window
object.
When called, the function executes puppeteerFunction
in node.js and returns a
Promise which resolves to the return value of puppeteerFunction
.
The name of the function on the window object.
This method fetches an element with selector and focuses it.
An array of all frames attached to the page.
Navigate to the previous page in history.
The navigation parameters.
Navigate to the next page in history.
The navigation parameters.
Navigates to a URL.
URL to navigate page to. The url should include scheme, e.g. https://
The navigation parameters.
This method fetches an element with selector
, scrolls it into view if needed,
and then uses page.mouse to hover over the center of the element. If there's no
element matching selector
, the method throws an error.
A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.
Indicates that the page has been closed.
true
if the page has JavaScript enabled, false
otherwise.
Page is guaranteed to have a main frame which persists during navigation's.
Gets the page metrics.
Adds the listener function to the end of the listeners array for the event named eventName
.
No checks are made to see if the listener has already been added. Multiple calls passing the same combination of
eventName
and listener will result in the listener being added, and called, multiple times.
The callback function.
Adds a one time listener function for the event named eventName
.
The next time eventName
is triggered, this listener is removed and then invoked.
The callback function.
Generates a PDF of the page with print
css media.
To generate a pdf with screen
media, call page.emulateMedia('screen')
before calling page.pdf()
:
The PDF parameters.
Reloads the current page.
The navigation parameters.
Captures a screenshot of the page.
The screenshot options.
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.
A selector to query page for.
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.
Toggles bypassing page's Content-Security-Policy. NOTE CSP bypassing happens at the moment of CSP initialization rather then evaluation. Usually this means that page.setBypassCSP should be called before navigating to the domain.
sets bypassing of page's Content-Security-Policy.
Determines whether cache is enabled on the page.
Sets the page content.
HTML markup to assign to the page.
The navigation parameters.
Sets the cookies on the page.
The cookies to set.
This setting will change the default maximum navigation time of 30 seconds for the following methods:
page.goto
page.goBack
page.goForward
page.reload
page.waitForNavigation
This setting will change the default maximum time for the following methods and related shortcuts:
page.goBack
page.goForward
page.goto
page.reload
page.setContent
page.waitFor
page.waitForFunction
page.waitForNavigation
page.waitForRequest
page.waitForResponse
page.waitForSelector
page.waitForXPath
NOTE page.setDefaultNavigationTimeout takes priority over page.setDefaultTimeout
The extra HTTP headers will be sent with every request the page initiates.
An object containing additional http headers to be sent with every request. All header values must be strings.
Sets the page's geolocation.
Determines whether JavaScript is enabled on the page.
Determines whether the offline mode is enabled.
When true
, enables the offline mode for the page.
Determines whether the request interception is enabled.
When true
the methods request.abort
, request.continue
and request.respond
must be used.
Specifies the User-Agent used in this page.
The user-agent to be used in the page.
Sets the viewport of the page.
The viewport parameters.
This method fetches an element with selector
, scrolls it into view if needed,
and then uses page.touchscreen to tap in the center of the element.
A selector
to search for element to tap. If there are multiple elements
satisfying the selector, the first will be tapped.
The target this page was created from
Returns the page's title.
Sends a keydown
, keypress/input
, and keyup
event for each character in the text.
A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used.
The page's URL. This is a shortcut for page.mainFrame().url()
Gets the page viewport.
In non-headless Chromium, this method results in the native file picker dialog not showing up for the user. This method is typically coupled with an action that triggers file choosing. This must be called before the file chooser is launched. It will not return a currently active file chooser.
Allows waiting for various conditions.
Wait for the page navigation occur.
The navigation parameters.
Causes your script to wait for the given number of milliseconds.
the number of milliseconds to wait.
This method returns all of the dedicated WebWorkers associated with the page.
Generated using TypeDoc
Page provides methods to interact with a single tab in Chromium. One Browser instance might have multiple Page instances.