Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source RSS

Page

Page provides methods to interact with a single tab in a running web browser. A single BrowserContext can have many pages.

MethodDescription
page.bringToFront()Activates a browser tab.
page.check(selector[, options])Select the input checkbox.
page.click(selector[, options])Clicks on an element matching a selector.
page.close()Closes a tab that the page is associated with.
page.content()Gets the HTML contents of the page.
page.context()Gets the BrowserContext that the page belongs to.
page.dblclick(selector[, options])With the Mouse, double click on an element matching the provided selector.
page.dispatchEvent(selector, type, eventInit[, options])Dispatches HTML DOM event types e.g. 'click'
page.$(selector)Finds an element matching the specified selector within the page.
page.$$(selector)Finds all elements matching the specified selector within the page.
page.emulateMedia([options])Changes the CSS media type and the color scheme feature.
page.emulateVisionDeficiency(type)Emulates your website with the specified vision deficiency type.
page.evaluate(pageFunction[, arg])Returns the value of the pageFunction invocation.
page.evaluateHandle(pageFunction[, arg])Returns the value of the pageFunction invocation as a JSHandle.
page.fill(selector, value[, options])Fill an input, textarea or contenteditable element with the provided value.
page.focus(selector[, options])Fetches an element with selector and focuses on it.
page.frames()Returns an array of frames on the page.
page.getAttribute(selector, name[, options])Returns the element attribute value for the given attribute name.
page.goto(url[, options])Navigates to the specified url.
page.hover(selector[, options])Hovers over an element matching selector.
page.innerHTML(selector[, options])Returns the element.innerHTML.
page.innerText(selector[, options])Returns the element.innerText.
page.inputValue(selector[, options])Returns input.value for the selected input, textarea or select element.
page.isChecked(selector[, options])Checks to see if the checkbox input type is selected or not.
page.isClosed() Checks if the page has been closed.
page.isDisabled(selector[, options])Checks if the element is disabled.
page.isEditable(selector[, options])Checks if the element is editable.
page.isEnabled(selector[, options])Checks if the element is enabled.
page.isHidden(selector[, options])Checks if the element is hidden.
page.isVisible(selector[, options])Checks if the element is visible.
page.keyboardReturns the Keyboard instance to interact with a virtual keyboard on the page.
page.locator(selector)Returns a Locator for the given selector.
page.mainFrame()Returns the page’s main Frame.
page.mouseReturns the Mouse instance to interact with a virtual mouse on the page.
page.on(event, handler)Registers a handler to be called whenever the specified event occurs.
page.opener()Returns the page that opened the current page.
page.press(selector, key[, options])Focuses the element, and then presses the given key on the Keyboard.
page.reload([options])Reloads the current page.
page.screenshot([options])Returns a buffer with the captured screenshot from the web browser.
page.selectOption(selector, values[, options])Selects one or more options which match the values from a <select> element.
page.setContent(html[, options])Sets the supplied HTML string to the current page.
page.setDefaultNavigationTimeout(timeout)Changes the navigation timeout for page.goto(url[, options]), page.reload([options]), page.setContent(html[, options]), and page.waitForNavigation([options])
page.setDefaultTimeout(timeout)Changes the timeout for all the methods accepting a timeout option.
page.setExtraHTTPHeaders(headers)Sets extra HTTP headers which will be sent with subsequent HTTP requests.
page.setViewportSize(viewportSize)Updates the page’s width and height.
page.tap(selector[, options])Taps the first element that matches the selector.
page.textContent(selector[, options])Returns the element.textContent.
page.throttleCPU(cpuProfile)Throttles the CPU in Chrome/Chromium to slow it down by the specified rate in the cpuProfile object.
page.throttleNetwork(networkProfile)Throttles the network in Chrome/Chromium to slow it down by the specified fields in the networkProfile object.
page.title()Returns the page’s title.
page.type(selector, text[, options])Types the text in the first element found that matches the selector.
page.touchScreenReturns the Touchscreen instance to interact with a virtual touchscreen on the page.
page.uncheck(selector[, options])Unselects an input checkbox element.
page.url()Returns the page’s URL.
page.viewportSize()Returns the page’s size (width and height).
page.waitForFunction(pageFunction, arg[, options])Returns when the pageFunction returns a truthy value.
page.waitForLoadState(state[, options]) Waits for the given load state to be reached.
page.waitForNavigation([options])Waits for the given navigation lifecycle event to occur and returns the main resource response.
page.waitForSelector(selector[, options])Returns when element specified by selector satisfies state option.
page.waitForTimeout(timeout)Waits for the given timeout in milliseconds.
page.workers()Returns an array of the dedicated WebWorkers associated with the page.