No results for

Powered byAlgolia
warning

This documentation is a work in progress, and some of the functionality that is listed below may not behave as expected.

Supported APIs

MethodPlaywright Relevant DistinctionsDescription
page.bringToFront()--
page.check(selector[, options])--
page.click(selector[, options])--
page.close([options])--
page.content()--
page.context()--
page.dblclick(selector[, options])--
page.dispatchEvent(selector, type[, eventInit, options])--
page.emulateMedia([options])--
page.evaluate(pageFunction[, arg])--
page.evaluateHandle(pageFunction[, arg])--
page.fill(selector, value[, options])--
page.focus(selector[, options])--
page.frames()--
page.getAttribute(selector, name[, options])--
page.goto(url[, options])--
page.hover(selector[, options])--
page.innerHTML(selector[, options])--
page.innerText(selector[, options])--
page.inputValue(selector[, options])--
page.isChecked(selector[, options])--
page.isClosed()--
page.isDisabled(selector[, options])--
page.isEditable(selector[, options])--
page.isEnabled(selector[, options])--
page.isHidden(selector[, options])--
page.isVisible(selector[, options])--
page.locator(selector[, options])-Creates and returns a new page locator given a selector with strict mode on. The strict mode only allows selecting a single matching element, and will throw an error if multiple matches are found.
page.mainFrame()--
page.opener()--
page.press(selector, key[, options])--
page.reload([options])--
page.screenshot([options])--
page.selectOption(selector, values[, options])--
page.setChecked(selector, checked[, options])--
page.setContent(html[, options])--
page.setDefaultNavigationTimeout(timeout)--
page.setDefaultTimeout(timeout)--
page.setExtraHTTPHeaders(headers)--
page.setInputFiles(selector, files[, options])--
page.setViewportSize(viewportSize)--
page.tap(selector[, options])--
page.textContent(selector[, options])--
page.title()--
page.type(selector, text[, options])--
page.uncheck(selector[, options])--
page.unroute(url[, handler])--
page.url()--
page.viewportSize()--
page.waitForFunction(pageFunction[, arg, options])--
page.waitForLoadState([state, options])--
page.waitForNavigation([options])--
page.waitForRequest(urlOrPredicate[, options])--
page.waitForResponse(urlOrPredicate[, options])--
page.waitForSelector(selector[, options])--
page.waitForTimeout(timeout)--
keyboard--
mouse--
touchscreen--

Example

import { check } from 'k6';
import { chromium } from 'k6/x/browser';
export default function() {
const browser = chromium.launch({
headless: false,
});
const context = browser.newContext();
const page = context.newPage();
// Goto front page, find login link and click it
page
.goto('https://test.k6.io/', { waitUntil: 'networkidle' })
.then(() => {
return Promise.all([
page.waitForNavigation(),
page.locator('a[href="/my_messages.php"]').click(),
]);
}).then(() => {
// Enter login credentials and login
page.locator('input[name="login"]').type('admin');
page.locator('input[name="password"]').type('123');
return Promise.all([
page.waitForNavigation(),
page.locator('input[type="submit"]').click(),
]);
}).then(() => {
check(page, {
'header': page.locator('h2').textContent() == 'Welcome, admin!',
});
}).finally(() => {
page.close();
browser.close();
});
}