---
title: "Page | Grafana k6 documentation"
description: "Browser module: Page Class"
---

# Page

Page provides methods to interact with a single tab in a running web browser. A single [BrowserContext](/docs/k6/latest/javascript-api/k6-browser/browsercontext/) can have many `pages`.

Expand table

| Method                                                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [$(selector)](/docs/k6/latest/javascript-api/k6-browser/page/page-dollar/)                                                                                     | Finds an element matching the specified `selector` within the page.                                                                                                                                                                                                                                                                                                                                                        |
| [$$(selector)](/docs/k6/latest/javascript-api/k6-browser/page/page-doubledollar/)                                                                              | Finds all elements matching the specified `selector` within the page.                                                                                                                                                                                                                                                                                                                                                      |
| [bringToFront()](/docs/k6/latest/javascript-api/k6-browser/page/bringtofront/)                                                                                 | Activates a browser tab.                                                                                                                                                                                                                                                                                                                                                                                                   |
| [check(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/check/)                                                                          | Select the input checkbox.                                                                                                                                                                                                                                                                                                                                                                                                 |
| [click(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/click/)                                                                          | Clicks on an element matching a `selector`.                                                                                                                                                                                                                                                                                                                                                                                |
| [close()](/docs/k6/latest/javascript-api/k6-browser/page/close/)                                                                                               | Closes a tab that the `page` is associated with.                                                                                                                                                                                                                                                                                                                                                                           |
| [content()](/docs/k6/latest/javascript-api/k6-browser/page/content/)                                                                                           | Gets the HTML contents of the page.                                                                                                                                                                                                                                                                                                                                                                                        |
| [context()](/docs/k6/latest/javascript-api/k6-browser/page/context/)                                                                                           | Gets the [BrowserContext](/docs/k6/latest/javascript-api/k6-browser/browsercontext/) that the page belongs to.                                                                                                                                                                                                                                                                                                             |
| [dblclick(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/dblclick/)                                                                    | With the [Mouse](/docs/k6/latest/javascript-api/k6-browser/mouse/), double click on an element matching the provided `selector`.                                                                                                                                                                                                                                                                                           |
| [dispatchEvent(selector, type, eventInit\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/dispatchevent/)                                         | Dispatches HTML DOM event types e.g. `'click'`                                                                                                                                                                                                                                                                                                                                                                             |
| [emulateMedia(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/emulatemedia/)                                                                      | Changes the CSS media type and the color scheme feature.                                                                                                                                                                                                                                                                                                                                                                   |
| [emulateVisionDeficiency(type)](/docs/k6/latest/javascript-api/k6-browser/page/emulatevisiondeficiency/)                                                       | Emulates your website with the specified vision deficiency `type`.                                                                                                                                                                                                                                                                                                                                                         |
| [evaluate(pageFunction\[, arg\])](/docs/k6/latest/javascript-api/k6-browser/page/evaluate/)                                                                    | Returns the value of the `pageFunction` invocation.                                                                                                                                                                                                                                                                                                                                                                        |
| [evaluateHandle(pageFunction\[, arg\])](/docs/k6/latest/javascript-api/k6-browser/page/evaluatehandle/)                                                        | Returns the value of the `pageFunction` invocation as a [JSHandle](/docs/k6/latest/javascript-api/k6-browser/jshandle/).                                                                                                                                                                                                                                                                                                   |
| [fill(selector, value\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/fill/)                                                                     | Fill an `input`, `textarea` or `contenteditable` element with the provided value.                                                                                                                                                                                                                                                                                                                                          |
| [focus(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/focus/)                                                                          | Fetches an element with `selector` and focuses on it.                                                                                                                                                                                                                                                                                                                                                                      |
| [frames()](/docs/k6/latest/javascript-api/k6-browser/page/frames/)                                                                                             | Returns an array of frames on the page.                                                                                                                                                                                                                                                                                                                                                                                    |
| [frameLocator(selector)](/docs/k6/latest/javascript-api/k6-browser/page/framelocator/)                                                                         | Returns a [FrameLocator](/docs/k6/latest/javascript-api/k6-browser/framelocator/) for the iframe matching the given `selector`.                                                                                                                                                                                                                                                                                            |
| [getAttribute(selector, name\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getattribute/)                                                      | Returns the element attribute value for the given attribute name.                                                                                                                                                                                                                                                                                                                                                          |
| [getByAltText(altText\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getbyalttext/)                                                             | Returns a locator for elements with the specified `alt` attribute text.                                                                                                                                                                                                                                                                                                                                                    |
| [getByLabel(text\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getbylabel/)                                                                    | Returns a locator for form controls with the specified label text.                                                                                                                                                                                                                                                                                                                                                         |
| [getByPlaceholder(placeholder\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getbyplaceholder/)                                                 | Returns a locator for input elements with the specified `placeholder` attribute text.                                                                                                                                                                                                                                                                                                                                      |
| [getByRole(role\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getbyrole/)                                                                      | Returns a locator for elements with the specified ARIA role.                                                                                                                                                                                                                                                                                                                                                               |
| [getByTestId(testId)](/docs/k6/latest/javascript-api/k6-browser/page/getbytestid/)                                                                             | Returns a locator for elements with the specified `data-testid` attribute.                                                                                                                                                                                                                                                                                                                                                 |
| [getByText(text\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getbytext/)                                                                      | Returns a locator for elements containing the specified text.                                                                                                                                                                                                                                                                                                                                                              |
| [getByTitle(title\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/getbytitle/)                                                                   | Returns a locator for elements with the specified `title` attribute.                                                                                                                                                                                                                                                                                                                                                       |
| [goBack(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/goback/)                                                                                  | Navigates back in the browser’s session history.                                                                                                                                                                                                                                                                                                                                                                           |
| [goForward(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/goforward/)                                                                            | Navigates forward in the browser’s session history.                                                                                                                                                                                                                                                                                                                                                                        |
| [goto(url\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/goto/)                                                                                 | Navigates to the specified `url`.                                                                                                                                                                                                                                                                                                                                                                                          |
| [hover(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/hover/)                                                                          | Hovers over an element matching `selector`.                                                                                                                                                                                                                                                                                                                                                                                |
| [innerHTML(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/innerhtml/)                                                                  | Returns the `element.innerHTML`.                                                                                                                                                                                                                                                                                                                                                                                           |
| [innerText(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/innertext/)                                                                  | Returns the `element.innerText`.                                                                                                                                                                                                                                                                                                                                                                                           |
| [inputValue(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/inputvalue/)                                                                | Returns `input.value` for the selected `input`, `textarea` or `select` element.                                                                                                                                                                                                                                                                                                                                            |
| [isChecked(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/ischecked/)                                                                  | Checks to see if the `checkbox` `input` type is selected or not.                                                                                                                                                                                                                                                                                                                                                           |
| [isClosed()](/docs/k6/latest/javascript-api/k6-browser/page/isclosed/) [](https://github.com/grafana/xk6-browser/issues/878)                                   | Checks if the page has been closed.                                                                                                                                                                                                                                                                                                                                                                                        |
| [isDisabled(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/isdisabled/)                                                                | Checks if the element is `disabled`.                                                                                                                                                                                                                                                                                                                                                                                       |
| [isEditable(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/iseditable/)                                                                | Checks if the element is `editable`.                                                                                                                                                                                                                                                                                                                                                                                       |
| [isEnabled(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/isenabled/)                                                                  | Checks if the element is `enabled`.                                                                                                                                                                                                                                                                                                                                                                                        |
| [isHidden(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/ishidden/)                                                                    | Checks if the element is `hidden`.                                                                                                                                                                                                                                                                                                                                                                                         |
| [isVisible(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/isvisible/)                                                                  | Checks if the element is `visible`.                                                                                                                                                                                                                                                                                                                                                                                        |
| [keyboard](/docs/k6/latest/javascript-api/k6-browser/page/keyboard/)                                                                                           | Returns the [Keyboard](/docs/k6/latest/javascript-api/k6-browser/keyboard/) instance to interact with a virtual keyboard on the page.                                                                                                                                                                                                                                                                                      |
| [locator(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/locator/)                                                                      | Returns a [Locator](/docs/k6/latest/javascript-api/k6-browser/locator/) for the given `selector`.                                                                                                                                                                                                                                                                                                                          |
| [mainFrame()](/docs/k6/latest/javascript-api/k6-browser/page/mainframe/)                                                                                       | Returns the page’s main [Frame](/docs/k6/latest/javascript-api/k6-browser/frame/).                                                                                                                                                                                                                                                                                                                                         |
| [mouse](/docs/k6/latest/javascript-api/k6-browser/page/mouse/)                                                                                                 | Returns the [Mouse](/docs/k6/latest/javascript-api/k6-browser/mouse/) instance to interact with a virtual mouse on the page.                                                                                                                                                                                                                                                                                               |
| [on(event, handler)](/docs/k6/latest/javascript-api/k6-browser/page/on/)                                                                                       | Registers a handler to be called whenever the specified event occurs.                                                                                                                                                                                                                                                                                                                                                      |
| [opener()](/docs/k6/latest/javascript-api/k6-browser/page/opener/)                                                                                             | Returns the `page` that opened the current `page`.                                                                                                                                                                                                                                                                                                                                                                         |
| [press(selector, key\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/press/)                                                                     | Focuses the element, and then presses the given `key` on the [Keyboard](/docs/k6/latest/javascript-api/k6-browser/keyboard/).                                                                                                                                                                                                                                                                                              |
| [reload(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/reload/)                                                                                  | Reloads the current page.                                                                                                                                                                                                                                                                                                                                                                                                  |
| [route(url, handler)](/docs/k6/latest/javascript-api/k6-browser/page/route/)                                                                                   | Adds a route to the page to modify network requests made by that page.                                                                                                                                                                                                                                                                                                                                                     |
| [screenshot(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/screenshot/)                                                                          | Returns a buffer with the captured screenshot from the web browser.                                                                                                                                                                                                                                                                                                                                                        |
| [selectOption(selector, values\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/selectoption/)                                                    | Selects one or more options which match the values from a `<select>` element.                                                                                                                                                                                                                                                                                                                                              |
| [setContent(html\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/setcontent/)                                                                    | Sets the supplied HTML string to the current page.                                                                                                                                                                                                                                                                                                                                                                         |
| [setChecked(selector, checked\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/setchecked/)                                                       | Sets the `checkbox` or `radio` input element’s value to the specified checked or unchecked state.                                                                                                                                                                                                                                                                                                                          |
| [setDefaultNavigationTimeout(timeout)](/docs/k6/latest/javascript-api/k6-browser/page/setdefaultnavigationtimeout/)                                            | Changes the navigation timeout for [page.goto(url\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/goto/), [page.reload(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/reload/), [page.setContent(html\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/setcontent/), and [page.waitForNavigation(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitfornavigation/) |
| [setDefaultTimeout(timeout)](/docs/k6/latest/javascript-api/k6-browser/page/setdefaulttimeout/)                                                                | Changes the timeout for all the methods accepting a `timeout` option.                                                                                                                                                                                                                                                                                                                                                      |
| [setExtraHTTPHeaders(headers)](/docs/k6/latest/javascript-api/k6-browser/page/setextrahttpheaders/)                                                            | Sets extra HTTP headers which will be sent with subsequent HTTP requests.                                                                                                                                                                                                                                                                                                                                                  |
| [setInputFiles(selector, file\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/setinputfiles/)                                                    | Sets the file input element’s value to the specified files.                                                                                                                                                                                                                                                                                                                                                                |
| [setViewportSize(viewportSize)](/docs/k6/latest/javascript-api/k6-browser/page/setviewportsize/)                                                               | Updates the `page`’s width and height.                                                                                                                                                                                                                                                                                                                                                                                     |
| [tap(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/tap/)                                                                              | Taps the first element that matches the `selector`.                                                                                                                                                                                                                                                                                                                                                                        |
| [textContent(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/textcontent/)                                                              | Returns the `element.textContent`.                                                                                                                                                                                                                                                                                                                                                                                         |
| [throttleCPU(cpuProfile)](/docs/k6/latest/javascript-api/k6-browser/page/throttlecpu/)                                                                         | Throttles the CPU in Chrome/Chromium to slow it down by the specified `rate` in the `cpuProfile` object.                                                                                                                                                                                                                                                                                                                   |
| [throttleNetwork(networkProfile)](/docs/k6/latest/javascript-api/k6-browser/page/throttlenetwork/)                                                             | Throttles the network in Chrome/Chromium to slow it down by the specified fields in the `networkProfile` object.                                                                                                                                                                                                                                                                                                           |
| [title()](/docs/k6/latest/javascript-api/k6-browser/page/title/)                                                                                               | Returns the `page`’s title.                                                                                                                                                                                                                                                                                                                                                                                                |
| [type(selector, text\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/type/)                                                                      | Types the `text` in the first element found that matches the `selector`.                                                                                                                                                                                                                                                                                                                                                   |
| [touchscreen](/docs/k6/latest/javascript-api/k6-browser/page/touchscreen/)                                                                                     | Returns the [Touchscreen](/docs/k6/latest/javascript-api/k6-browser/touchscreen/) instance to interact with a virtual touchscreen on the page.                                                                                                                                                                                                                                                                             |
| [uncheck(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/uncheck/)                                                                      | Unselects an input `checkbox` element.                                                                                                                                                                                                                                                                                                                                                                                     |
| [unroute(url)](/docs/k6/latest/javascript-api/k6-browser/page/unroute/)                                                                                        | Removes all existing routes for the `url`.                                                                                                                                                                                                                                                                                                                                                                                 |
| [unrouteAll()](/docs/k6/latest/javascript-api/k6-browser/page/unrouteall/)                                                                                     | Removes all routes created with [`page.route()`](/docs/k6/latest/javascript-api/k6-browser/page/route/).                                                                                                                                                                                                                                                                                                                   |
| [url()](/docs/k6/latest/javascript-api/k6-browser/page/url/)                                                                                                   | Returns the `page`’s URL.                                                                                                                                                                                                                                                                                                                                                                                                  |
| [viewportSize()](/docs/k6/latest/javascript-api/k6-browser/page/viewportsize/)                                                                                 | Returns the `page`’s size (width and height).                                                                                                                                                                                                                                                                                                                                                                              |
| [waitForEvent(event\[, optionsOrPredicate\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforevent/)                                                    | Waits for the specified event to be emitted.                                                                                                                                                                                                                                                                                                                                                                               |
| [waitForFunction(pageFunction, arg\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforfunction/)                                             | Returns when the `pageFunction` returns a truthy value.                                                                                                                                                                                                                                                                                                                                                                    |
| [waitForLoadState(state\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforloadstate/) [](https://github.com/grafana/xk6-browser/issues/880) | Waits for the given load `state` to be reached.                                                                                                                                                                                                                                                                                                                                                                            |
| [waitForNavigation(\[options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitfornavigation/)                                                            | Waits for the given navigation lifecycle event to occur and returns the main resource response.                                                                                                                                                                                                                                                                                                                            |
| [waitForRequest(urlPattern\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforrequest/)                                                      | Waits for an HTTP request that matches the specified URL pattern.                                                                                                                                                                                                                                                                                                                                                          |
| [waitForResponse(urlPattern\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforresponse/)                                                    | Waits for an HTTP response that matches the specified URL pattern.                                                                                                                                                                                                                                                                                                                                                         |
| [waitForSelector(selector\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforselector/)                                                      | Returns when element specified by selector satisfies `state` option.                                                                                                                                                                                                                                                                                                                                                       |
| [waitForTimeout(timeout)](/docs/k6/latest/javascript-api/k6-browser/page/waitfortimeout/)                                                                      | Waits for the given `timeout` in milliseconds.                                                                                                                                                                                                                                                                                                                                                                             |
| [waitForURL(url\[, options\])](/docs/k6/latest/javascript-api/k6-browser/page/waitforurl/)                                                                     | Waits for the page to navigate to the specified URL.                                                                                                                                                                                                                                                                                                                                                                       |
| [workers()](/docs/k6/latest/javascript-api/k6-browser/page/workers/)                                                                                           | Returns an array of the dedicated [WebWorkers](/docs/k6/latest/javascript-api/k6-browser/worker/) associated with the page.                                                                                                                                                                                                                                                                                                |
