TypeScript SDK: Browser: opening a page
Use the browser for dynamic pages and interactions. Opening is asynchronous; close the page after use.
Each example is a separate fragment inside async function run(ctx: Akmelo.Context): Promise<void>. Use await only for methods whose signature returns a Promise.
Methods
open
ctx.browser().open(url, capture, captchaHints, autoCaptcha = true) → Promise<BrowserPage>
Open a page in the managed browser.
const result = await ctx.browser().open(ctx.param('catalog_url', 'https://example.com'));
Automatic CAPTCHA handling
autoCaptcha is optional and defaults to true. Pass false to disable automatic solving. With automatic mode disabled, the request does not start paid CAPTCHA tasks. Platform and site settings, supported challenge types and quotas still apply. The choice applies to the entire browser session, including subsequent actions and content reads.
const page = await ctx.browser().open(url, [], {}, false);
CAPTCHA on a self-hosted agent
Automatic mode and opt-out also work on your agent. A browser, connectivity to Akmelo and an eligible plan are required. No additional CAPTCHA keys need to be configured. Checks and costs belong to the agent's workspace; local execution does not make CAPTCHA handling free.
Yandex SmartCaptcha practice
The official demo allows a complete form check without an external account. CAPTCHA handling runs automatically; the script fills in a sample name and submits the form. Use only test values.
const page = await ctx.browser().open('https://smartcaptcha.yandexcloud.net/demo', [], { success_selector: '.greeting' });
try {
await page.type('#name', 'Training example');
await page.click('#smartcaptcha-demo-submit');
await page.waitFor('.greeting', 15000);
ctx.log(ctx.dom(await page.content()).text('.greeting') ?? '');
} finally { await page.close(); }
A filled smart-token means the form is ready to submit. Only the server greeting with the submitted name confirms success. The CAPTCHA title and the new empty widget next to the greeting do not trigger another payment during result reading. A further visual challenge is processed in the same session up to the run limit; cancellation and deadlines stop the chain. An unsupported challenge or a rejected answer remains an error. The same SDK methods and hints work on a connected agent.
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.
Object selection with explicit selectors
Replace these example selectors with elements from your source. Both image selectors must identify the challenge images, not the whole page. Use this only when automatic discovery is insufficient.
const page = await ctx.browser().open(url, [], {
kind: 'yandex_image',
image_selector: '.challenge-image',
instructions_selector: '.challenge-order',
submit_selector: '.challenge-submit',
success_selector: '.result',
});
try {
await page.waitFor('.result', 15000);
} finally { await page.close(); }