// DOCUMENTATION

Page & Locators

Playwright-style page methods, locators, and wait strategies.

SDK Reference

The SDK mirrors Playwright's page and locator API so existing automation scripts port with minimal edits.

Navigation

await page.goto(url, { waitUntil: "domcontentloaded" });
await page.goto(url, { waitUntil: "done" }); // Koko-specific
await page.reload();
await page.goBack();
await page.goForward();

waitUntil options: none, commit, domcontentloaded, load, networkidle, done.

Locators

await page.locator("button.submit").click();
await page.getByRole("button", { name: "Submit" }).click();
await page.getByText("Sign in").click();
await page.getByLabel("Email").fill("user@example.com");
await page.getByPlaceholder("Search...").fill("query");
await page.getByAltText("Logo").click();
await page.getByTitle("Close").click();
await page.getByTestId("submit-btn").click();

Locator actions

await locator.click();
await locator.fill("text");
await locator.hover();
await locator.check();
await locator.uncheck();
await locator.selectOption("value");
const text = await locator.textContent();
const count = await locator.count();
await locator.first().click();
await locator.nth(2).click();

Selector shortcuts

await page.click("button.submit");
await page.fill('textarea[name="q"]', "Koko browser");
await page.press("Enter");
await page.type("input", "text"); // alias for fill

Wait strategies

await page.waitForSelector(".loaded");
await page.waitForNavigation();
await page.waitForURL(/dashboard/);
await page.waitForFunction(() => window.ready === true);

waitForSelector() uses DOM.performSearch when visibility is not required — faster for crawl workloads.

Page utilities

const html = await page.content();
const title = await page.title();
const url = await page.url();
const png = await page.screenshot({ type: "png" });
const pdf = await page.pdf();
const result = await page.evaluate(() => document.title);