Menu

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