Skip to main content
Navigate to URLs and monitor page loading with the Page navigation API.

Methods

page.goto()

Navigates to a URL. Returns true if navigation succeeded, false otherwise.
Parameters:
  • url: URL to navigate to
  • headers (optional): Custom HTTP headers to send with the request
  • timeout (optional): Navigation timeout in milliseconds (default: varies)
Returns: Promise<boolean> - true if navigation succeeded Examples:
Use waitForSelector() after goto() to ensure specific content has loaded before proceeding.

page.url()

Gets the current page URL.
Returns: Promise<string> - Current URL Example:

page.progress()

Gets page load progress as a percentage (0-100).
Returns: Promise<number> - Load progress percentage Example:

page.show()

Brings the page to the foreground, making it visible to the user.
Parameters:
  • animate (optional): Whether to animate the transition (default: true)
Returns: Promise<void> Example:

page.hide()

Hides the page, removing it from view.
Parameters:
  • animate (optional): Whether to animate the transition (default: true)
Returns: Promise<void> Example:
Use show() and hide() to manage multiple pages in a browser, similar to switching tabs.

page.setUserAgent()

Sets a custom User-Agent string for the page.
Parameters:
  • userAgent: User-Agent string to set
Returns: Promise<void> Example:
Common user agents:
Set the user agent before navigating to ensure it’s applied to all requests on the page.

Complete examples

Handling redirects

Authenticated navigation

Progress monitoring

Single-page application navigation

Error handling

Waiting

Wait for content after navigation

Events

Monitor navigation events

Page overview

Back to Page API overview