Python SDK: BrowserPage: page actions
Get a page with ctx.browser().open(url). Actions are synchronous. Wait for new data after a click or navigation and always call close() in finally.
Examples are fragments inside def run(ctx):. All SDK methods are synchronous; do not add await.
Obtaining the SDK object
page = ctx.browser().open(ctx.param('catalog_url'))
try:
page.wait_for('.product')
ctx.log('HTML loaded', {'length': len(page.content())})
finally:
page.close()
Methods
goto()click()type()scroll()wait_for()hover()scroll_to()select()press()content()screenshot()close()capture_responses()responses()wait_for_response()
goto
page.goto(url) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
url |
str |
Yes | Permitted source HTTP(S) URL. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Navigate to another URL in the same browser page.
result = page.goto(ctx.param('next_url'))
click
page.click(selector, timeout_ms=5000) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Click the first element matching the selector.
result = page.click('button.next', 5000)
type
page.type(selector, text) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
text |
str |
Yes | Text to parse, search, or type. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Enter text in a matching field.
result = page.type('input.search', 'cable')
scroll
page.scroll(times=1, delay_ms=500) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
times |
int |
No, see the signature default | Maximum scroll-step count. |
delay_ms |
int |
No, see the signature default | Delay between scroll steps, milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Scroll down in steps, with a pause between them.
result = page.scroll(2, 500)
wait_for
page.wait_for(selector, timeout_ms=10000) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Wait for an element matching the selector.
result = page.wait_for('.product', 10000)
hover
page.hover(selector, timeout_ms=5000) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Move the pointer over an element to open a menu or tooltip: page.hover('.catalog-menu');.
result = page.hover('.catalog-menu', 5000)
scroll_to
page.scroll_to(selector, timeout_ms=5000) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Scroll to a specific element: page.scroll_to('.product-card');.
result = page.scroll_to('.product', 5000)
select
page.select(selector, value, timeout_ms=5000) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
value |
Any |
Yes | Method-specific value; see its result description. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Select a native dropdown value: page.select('select.city', 'perm');.
result = page.select('select.city', 'perm', 5000)
press
page.press(selector, key, timeout_ms=5000) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
key |
str | None |
Yes | Record, state, object, or workflow-input key, depending on the method. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
Press a key in an element: page.press('input.search', 'Enter');.
result = page.press('input.search', 'Enter', 5000)
content
page.content() -> str
No arguments.
Result: str.
Get the current HTML after browser actions.
result = page.content()
screenshot
page.screenshot() -> str
No arguments.
Result: str.
Save an image of the current page.
result = page.screenshot()
close
page.close() -> None
No arguments.
Result: None. The method does not return a data value.
Releases the open page. Call it in finally, including after a failed action.
result = page.close()
capture_responses
page.capture_responses(patterns) -> BrowserPage
| Argument | Type | Required | Purpose |
|---|---|---|---|
patterns |
list[str] |
Yes | Capture URL patterns; an empty list disables capture. |
Result: BrowserPage. An SDK object; use its methods instead of emitting it directly.
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().
result = page.capture_responses(['*/api/products*'])
responses
page.responses() -> dict[str, Any]
No arguments.
Result: dict[str, Any].
Returns network responses captured with capture_responses(). Data becomes available after relevant page actions.
result = page.responses()
wait_for_response
page.wait_for_response(pattern='*', timeout_ms=10000) -> dict[str, Any] | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
pattern |
str |
No, see the signature default | Regular expression or URL pattern, depending on the method. |
timeout_ms |
int |
No, see the signature default | Wait timeout in milliseconds. |
Result: dict[str, Any] | None.
Waits for a network response matching the pattern. Use a bounded timeout and handle a None result.
result = page.wait_for_response('*/api/products*', 10000)
Errors and execution context
All calls are synchronous. Invalid arguments or malformed source data can raise ValueError/TypeError; a platform refusal or unavailable service raises RuntimeError. Missing elements/values return None or an empty collection only where explicitly documented. Do not convert every exception into an empty successful result. External-service methods are unavailable in export transformations; see transformation limits and environment.
solve_captcha
page.solve_captcha(hints=None) -> BrowserPage
Complete a supported site challenge. Normally handled automatically.
page.solve_captcha({"success_selector": ".loaded-products"})
The success element must appear after completion. Pass hints before navigation with ctx.browser().open(url, captcha_hints={"success_selector": ".product-card"}). A separate allowance applies without AI tokens. Unsupported types and unconfirmed access raise an error. Never enter a site secret key.
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.