Skip to content

Documentation

JavaScript SDK: BrowserPage: page actions

Get a page with await ctx.browser().open(url). Actions are asynchronous. Wait for new data after a click or navigation and always call close() in finally.

Each example is a separate fragment inside async function run(ctx). Use await only for methods whose signature returns a Promise.

Obtaining the object

const page = await ctx.browser().open(ctx.param('catalog_url', 'https://example.com'));
try {
  await page.waitFor('.product');
  const html = await page.content();
  ctx.log(String(html.length));
} finally {
  await page.close();
}

Methods

goto

page.goto(url) → Promise<BrowserPage>

Navigate to another URL in the same browser page.

const result = await page.goto('https://example.com/catalog?page=2');

click

page.click(selector, timeoutMs) → Promise<BrowserPage>

Click the first element matching the selector.

const result = await page.click('button.next');

type

page.type(selector, text) → Promise<BrowserPage>

Enter text in a matching field.

const result = await page.type('input.search', 'product');

scroll

page.scroll(times, delayMs) → Promise<BrowserPage>

Scroll down in steps, with a pause between them.

const result = await page.scroll();

waitFor

page.waitFor(selector, timeoutMs) → Promise<BrowserPage>

Wait for an element matching the selector.

const result = await page.waitFor('.product');

hover

page.hover(selector, timeoutMs) → Promise<BrowserPage>

Move the pointer over an element to open a menu or tooltip: page.hover('.catalog-menu');.

const result = await page.hover('.catalog-menu');

scrollTo

page.scrollTo(selector, timeoutMs) → Promise<BrowserPage>

Scroll to a specific element: page.scrollTo('.product-card');.

const result = await page.scrollTo('.product');

select

page.select(selector, value, timeoutMs) → Promise<BrowserPage>

Select a native dropdown value: page.select('select.city', 'perm');.

const result = await page.select('select.city', 'perm');

press

page.press(selector, key, timeoutMs) → Promise<BrowserPage>

Press a key in an element: page.press('input.search', 'Enter');.

const result = await page.press('input.search', 'Enter');

content

page.content() → Promise<string>

Get the current HTML after browser actions.

const result = await page.content();

screenshot

page.screenshot() → Promise<string>

Save an image of the current page.

const result = await page.screenshot();

close

page.close() → Promise<void>

Releases the open page. Call it in finally, including after a failed action.

await page.close();

captureResponses

page.captureResponses(patterns) → Promise<BrowserPage>

Start capturing XHR/fetch responses matching full URL patterns. At most 20 patterns, each up to 1024 characters. A new configuration clears the old buffer; [] disables capture. Past requests cannot be recovered. To capture the initial navigation, use the second argument of browser().open().

await page.captureResponses(['*/api/products*']);

responses

page.responses() → Promise<object>

Returns network responses captured with captureResponses(). Data becomes available after relevant page actions.

const result = await page.responses();

waitForResponse

page.waitForResponse(pattern, timeoutMs) → Promise<object | null>

Waits for a network response matching the pattern. Use a bounded timeout and handle a null result.

const result = await page.waitForResponse('*/api/products*');

solveCaptcha

page.solveCaptcha(hints) → Promise<BrowserPage>

Complete a supported challenge in the current page. Normally handled automatically.

await page.solveCaptcha({ success_selector: '.loaded-products' });

The success element must appear only after completion. A separate allowance applies. Unsupported challenges and unconfirmed access stop execution.

Pass hints before navigation as the third argument of open(url, [], hints). Supported keys: kind, sitekey, action, invisible, callback, success_selector, submit_selector, image_selector, instructions_selector, answer_selector.

CAPTCHA usage reference

Complete CAPTCHA SDK and REST reference covers all hint fields, automatic defaults, explicit calls, session opt-out, result verification, agents, limits and failures. User guide and current prices explain setup and billing.

Object selection uses kind: "yandex_image"; automatic detection normally needs no hints. image_selector identifies only the task image, instructions_selector the selection order, and success_selector a result that appears after success. No target-domain list is needed. Unsupported variants fail instead of returning fabricated data. Do not repeatedly retry the same rejected task.

For yandex_text, answer_selector identifies the text answer input when it cannot be detected automatically. See the full hints contract in the CAPTCHA API reference.