|
| 1 | +--- |
| 2 | +title: "Page" |
| 3 | +excerpt: "Browser module: Page Class" |
| 4 | +--- |
| 5 | + |
| 6 | +Page provides methods to interact with a single tab in a running web browser. A single [BrowserContext](https://k6.io/docs/javascript-api/k6-experimental/browser/browsercontext/) can have many `pages`. |
| 7 | + |
| 8 | +| Method | Description | |
| 9 | +|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------| |
| 10 | +| [page.bringToFront()](/javascript-api/k6-experimental/browser/page/bringtofront/) | Activates a browser tab. | |
| 11 | +| [page.check(selector[, options])](/javascript-api/k6-experimental/browser/page/check/) | Select the input checkbox. | |
| 12 | +| [page.click(selector[, options])](/javascript-api/k6-experimental/browser/page/click/) | Clicks on an element matching a `selector`. | |
| 13 | +| [page.close()](/javascript-api/k6-experimental/browser/page/close/) | Closes a tab that the `page` is associated with. | |
| 14 | +| [page.content()](/javascript-api/k6-experimental/browser/page/content/) | Gets the HTML contents of the page. | |
| 15 | +| [page.context()](/javascript-api/k6-experimental/browser/page/context/) | Gets the [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) that the page belongs to. | |
| 16 | +| [page.dblclick(selector[, options])](/javascript-api/k6-experimental/browser/page/dblclick/) | With the [Mouse](https://k6.io/docs/javascript-api/k6-experimental/browser/mouse/), double click on an element matching the provided `selector`. | |
| 17 | +| [page.dispatchEvent(selector, type, eventInit[, options])](/javascript-api/k6-experimental/browser/page/dispatchevent/) | Dispatches HTML DOM event types e.g. `'click'` | |
| 18 | +| [page.$(selector)](/javascript-api/k6-experimental/browser/page/page-$/) | Finds an element matching the specified `selector` within the page. | |
| 19 | +| [page.$$(selector)](/javascript-api/k6-experimental/browser/page/page-$$/) | Finds all elements matching the specified `selector` within the page. | |
| 20 | +| [page.emulateMedia([options])](/javascript-api/k6-experimental/browser/page/emulatemedia/) | Changes the CSS media type and the color scheme feature. | |
| 21 | +| [page.emulateVisionDeficiency(type)](/javascript-api/k6-experimental/browser/page/emulatevisiondeficiency/) | Emulates your website with the specified vision deficiency `type`. | |
| 22 | +| [page.evaluate(pageFunction[, arg])](/javascript-api/k6-experimental/browser/page/evaluate/) | Returns the value of the `pageFunction` invocation. | |
| 23 | +| [page.evaluateHandle(pageFunction[, arg])](/javascript-api/k6-experimental/browser/page/evaluate/) | Returns the value of the `pageFunction` invocation as a [JSHandle](javascript-api/k6-experimental/browser/jshandle/). | |
| 24 | +| [page.fill(selector, value[, options])](/javascript-api/k6-experimental/browser/page/fill/) | Fill an `input`, `textarea` or `contenteditable` element with the provided value. | |
| 25 | +| [page.focus(selector[, options])](/javascript-api/k6-experimental/browser/page/focus/) | Fetches an element with `selector` and focuses on it. | |
| 26 | +| [page.frames()](/javascript-api/k6-experimental/browser/page/frames/) | Returns an array of frames on the page. | |
| 27 | +| [page.getAttribute(selector, name[, options])](/javascript-api/k6-experimental/browser/page/getattribute/) | Returns the element attribute value for the given attribute name. | |
| 28 | +| [page.goto(url[, options])](/javascript-api/k6-experimental/browser/page/goto/) | Navigates to the specified `url`. | |
| 29 | +| [page.hover(selector[, options])](/javascript-api/k6-experimental/browser/page/hover/) | Hovers over an element matching `selector`. | |
| 30 | +| [page.innerHTML(selector[, options])](/javascript-api/k6-experimental/browser/page/innerhtml/) | Returns the `element.innerHTML`. | |
| 31 | +| [page.innerText(selector[, options])](/javascript-api/k6-experimental/browser/page/innertext/) | Returns the `element.innerText`. | |
| 32 | +| [page.inputValue(selector[, options])](/javascript-api/k6-experimental/browser/page/inputvalue/) | Returns `input.value` for the selected `input`, `textarea` or `select` element. | |
| 33 | +| [page.isChecked(selector[, options])](/javascript-api/k6-experimental/browser/page/ischecked/) | Checks to see if the `checkbox` `input` type is selected or not. | |
| 34 | +| [page.isClosed()](/javascript-api/k6-experimental/browser/page/isclosed/) <BWIPT id="878"/> | Checks if the page has been closed. | |
| 35 | +| [page.isDisabled(selector[, options])](/javascript-api/k6-experimental/browser/page/isdisabled/) | Checks if the element is `disabled`. | |
| 36 | +| [page.isEditable(selector[, options])](/javascript-api/k6-experimental/browser/page/iseditable/) | Checks if the element is `editable`. | |
| 37 | +| [page.isEnabled(selector[, options])](/javascript-api/k6-experimental/browser/page/isenabbled/) | Checks if the element is `enabled`. | |
| 38 | +| [page.isHidden(selector[, options])](/javascript-api/k6-experimental/browser/page/ishidden/) | Checks if the element is `hidden`. | |
| 39 | +| [page.isVisible(selector[, options])](/javascript-api/k6-experimental/browser/page/isvisible/) | Checks if the element is `visible`. | |
| 40 | +| [page.keyboard](/javascript-api/k6-experimental/browser/page/keyboard/) | Returns the [Keyboard](javascript-api/k6-experimental/browser/keyboard/) instance to interact with a virtual keyboard on the page. | |
| 41 | +| [page.locator(selector)](/javascript-api/k6-experimental/browser/page/locator/) | Returns a [Locator](/javascript-api/k6-experimental/browser/locator/) for the given `selector`. | |
| 42 | +| [page.mainFrame()](/javascript-api/k6-experimental/browser/page/mainframe/) | Returns the page's main [Frame](https://k6.io/docs/javascript-api/k6-experimental/browser/frame/). | |
| 43 | +| [page.mouse](/javascript-api/k6-experimental/browser/page/mouse/) | Returns the [Mouse](javascript-api/k6-experimental/browser/mouse/) instance to interact with a virtual mouse on the page. | |
| 44 | +| [page.opener()](/javascript-api/k6-experimental/browser/page/opener/) | Returns the `page` that opened the current `page`. | |
| 45 | +| [page.press(selector, key[, options])](/javascript-api/k6-experimental/browser/page/press/) | Focuses the element, and then presses the given `key` on the [Keyboard](https://k6.io/docs/javascript-api/k6-experimental/browser/keyboard/). | |
| 46 | +| [page.reload([options])](/javascript-api/k6-experimental/browser/page/reload/) | Reloads the current page. | |
| 47 | +| [page.screenshot([options])](/javascript-api/k6-experimental/browser/page/screenshot/) | Returns a buffer with the captured screenshot from the web browser. | |
| 48 | +| [page.selectOption(selector, values[, options])](/javascript-api/k6-experimental/browser/page/selectoption/) | Selects one or more options which match the values from a `<select>` element. | |
| 49 | +| [page.setContent(html[, options])](/javascript-api/k6-experimental/browser/page/setcontent/) | Sets the supplied HTML string to the current page. | |
| 50 | +| [page.setDefaultNavigationTimeout(timeout)](/javascript-api/k6-experimental/browser/page/setdefaultnavigationtimeout/) | Changes the navigation timeout for [page.goto(url[, options])](/javascript-api/k6-experimental/browser/page/goto/), [page.reload([options])](/javascript-api/k6-experimental/browser/page/reload/), [page.setContent(html[, options])](/javascript-api/k6-experimental/browser/page/setcontent/), and [page.waitForNavigation([options])](/javascript-api/k6-experimental/browser/page/waitfornavigation/) | |
| 51 | +| [page.setDefaultTimeout(timeout)](/javascript-api/k6-experimental/browser/page/setdefaulttimeout/) | Changes the timeout for all the methods accepting a `timeout` option. | |
| 52 | +| [page.setExtraHTTPHeaders(headers)](/javascript-api/k6-experimental/browser/page/setextrahttpheaders/) | Sets extra HTTP headers which will be sent with subsequent HTTP requests. | |
| 53 | +| [page.setViewportSize(viewportSize)](/javascript-api/k6-experimental/browser/page/setviewportsize/) | Updates the `page`'s width and height. | |
| 54 | +| [page.tap(selector[, options])](/javascript-api/k6-experimental/browser/page/tap/) | Taps the first element that matches the `selector`. | |
| 55 | +| [page.textContent(selector[, options])](/javascript-api/k6-experimental/browser/page/textcontent/) | Returns the `element.textContent`. | |
| 56 | +| [page.title()](/javascript-api/k6-experimental/browser/page/title/) | Returns the `page`'s title. | |
| 57 | +| [page.type(selector, text[, options])](/javascript-api/k6-experimental/browser/page/type/) | Types the `text` in the first element found that matches the `selector`. | |
| 58 | +| [page.touchScreen](/javascript-api/k6-experimental/browser/page/touchscreen/) | Returns the [Touchscreen](/javascript-api/k6-experimental/browser/touchscreen/) instance to interact with a virtual touchscreen on the page. | |
| 59 | +| [page.uncheck(selector[, options])](/javascript-api/k6-experimental/browser/page/uncheck/) | Unselects an input `checkbox` element. | |
| 60 | +| [page.url()](/javascript-api/k6-experimental/browser/page/url/) | Returns the `page`'s URL. | |
| 61 | +| [page.viewportSize()](/javascript-api/k6-experimental/browser/page/viewportsize/) | Returns the `page`'s size (width and height). | |
| 62 | +| [page.waitForFunction(pageFunction, arg[, options])](/javascript-api/k6-experimental/browser/page/waitforfunction/) | Returns when the `pageFunction` returns a truthy value. | |
| 63 | +| [page.waitForLoadState(state[, options])](/javascript-api/k6-experimental/browser/page/waitforloadstate/) <BWIPT id="880"/> | Waits for the given load `state` to be reached. | |
| 64 | +| [page.waitForNavigation([options])](/javascript-api/k6-experimental/browser/page/waitfornavigation/) | Waits for the given navigation lifecycle event to occur and returns the main resource response. | |
| 65 | +| [page.waitForSelector(selector[, options])](/javascript-api/k6-experimental/browser/page/waitforselector/) | Returns when element specified by selector satisfies `state` option. | |
| 66 | +| [page.waitForTimeout(timeout)](/javascript-api/k6-experimental/browser/page/waitfortimeout/) | Waits for the given `timeout` in milliseconds. | |
| 67 | +| [page.workers()](/javascript-api/k6-experimental/browser/page/workers/) | Returns an array of the dedicated [WebWorkers](https://k6.io/docs/javascript-api/k6-experimental/browser/worker/) associated with the page. | |
0 commit comments