page
Accesses a page by navigating to a URL, loading HTML content, or returning the current page. This is the primary entry point for interacting with web pages, so you may want to create a page as the first step in your query or mutation.
- If
url
is provided, navigates to that URL. - If
content
is provided, creates a new page with that HTML content. - If neither
url
norcontent
is provided, returns the currently active page, if any.
Page options can be specified to configure aspects like viewport, user agent, headers, etc.
Examples
Definition
Arguments
url
: URL
The URL to navigate the page to. If specified, the browser will attempt to load this URL.
Example: "https://example.com"
content
: String
HTML content to set for the page. If specified, a new page is created with this content.
This is useful for testing static HTML snippets or pages constructed on-the-fly.
Example: "<html><body><h1>Test Page</h1></body></html>"
options
: PageOptions
Options to configure the page’s behavior and environment.
These include settings for viewport, user agent, geolocation, HTTP headers, JavaScript enablement, and more.
See PageOptions
for detailed configuration.
Returns
Represents a single tab or window in a web browser. The Page type provides methods to interact with the web page loaded in that tab. It implements the Node interface, giving access to element querying capabilities, and also offers page-specific information and actions like accessing URL, title, content, cookies, etc.