---
title: "Automate browser actions"
description: "Fill a field, click a button, and read a result with Kitsune."
canonical_url: "https://kitsune.carsxe.com/docs/guides/browser-control"
markdown_url: "https://kitsune.carsxe.com/docs/guides/browser-control.md"
last_updated: "2026-11-24"
x_farming_labs_generated_preamble: true
---

# Automate browser actions
URL: /docs/guides/browser-control
LLM index: /llms.txt
Description: Fill a field, click a button, and read a result with Kitsune.

# Automate browser actions

Use the browser methods when a page needs input before it shows the data you want. This example works with a self-contained page.

## Fill and submit a form

After [setting up Kitsune](/docs/typescript), save this as `browser.ts` at the repository root:

```ts
import { Kitsune } from 'kitsune'

const page = `
  <form onsubmit="event.preventDefault(); document.querySelector('output').textContent = this.elements.name.value">
    <label>Name <input name="name"></label>
    <button type="submit">Show result</button>
  </form>
  <output></output>
`

const kit = await Kitsune.launch()

try {
  await kit.goto('data:text/html,' + encodeURIComponent(page))
  await kit.type('input[name="name"]', 'Kitsune')
  await kit.click('button[type="submit"]')

  if (!(await kit.waitForText('Kitsune', 5_000))) {
    throw new Error('The form did not show a result')
  }

  console.log(await kit.text('output'))
} finally {
  await kit.close()
}
```

Run `bun run browser.ts`. It prints `Kitsune` after the form updates.

## Wait for a result

`goto()` waits for the page load event, then settles for two seconds by default. For content that appears after an action, use `waitFor(selector)` or `waitForText(text)`. Both return `false` on timeout, so check the return value before reading.

## The error

Before an action like `click()` or `type()`, Kitsune checks that the element can receive input. If it times out, the error gives the selector and the check that failed, such as `visible`, `enabled`, or `unobscured`. Inspect the matching element in Chrome and check for overlays or disabled controls.

See the [Kitsune API](/docs/reference/kit-api) for screenshots, files, frames, and other browser methods.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
