Skip to content

Playwright

Playwright actions enable modern browser automation (Chromium, Firefox, WebKit).

Important note: only methods decorated with @decorators.robotaction are user actions and are documented here.

Actions

playwright.check

Check checkbox/radio.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
  • force (optional, default False)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.click

Click locator.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
  • button (optional, default left)
  • click_count (optional, default 1)
  • delay (optional, default 0)
  • force (optional, default False)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.close

Close current Playwright resources and reset manager state.

Parameters:
  • browser — browser metadata object.
Return:
  • browserNone.

playwright.evaluate_js

Execute JavaScript expression on page or locator.

Parameters:
  • browser
  • expression
  • locator (optional)
  • timeout (optional, default 30000)
Return:
  • result

playwright.fill

Fill locator with value.

Parameters:
  • browser
  • locator (required)
  • value (optional, default empty string)
  • timeout (optional, default 30000)
  • force (optional, default False)
  • no_wait_after (optional, default False)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.get_attribute

Get attribute value from locator.

Parameters:
  • browser
  • locator (required)
  • name (required)
  • timeout (optional, default 30000)
Return:
  • value
Exceptions:
  • ElementNotFound when locator is missing.
  • ValueError when name is empty.

playwright.get_by_alt_text

Locate element by alt text.

Parameters:
  • browser
  • text
  • exact (optional, default False)
Return:
  • locator

playwright.get_by_label

Locate form control by label text.

Parameters:
  • browser
  • text
  • exact (optional, default False)
Return:
  • locator

playwright.get_by_placeholder

Locate input by placeholder text.

Parameters:
  • browser
  • text
  • exact (optional, default False)
Return:
  • locator

playwright.get_by_role

Locate element by ARIA role.

Parameters:
  • browser
  • role
  • name (optional)
  • exact (optional, default False)
Return:
  • locator

playwright.get_by_test_id

Locate element by data-testid.

Parameters:
  • browser
  • test_id
Return:
  • locator

playwright.get_by_text

Locate element by text.

Parameters:
  • browser
  • text
  • exact (optional, default False)
Return:
  • locator

playwright.get_by_title

Locate element by title attribute.

Parameters:
  • browser
  • text
  • exact (optional, default False)
Return:
  • locator

playwright.get_element

Compatibility action that returns one locator for selector.

Parameters:
  • browser
  • selector
  • index (optional)
Return:
  • element — locator object.

playwright.get_elements

Return all locators matching selector.

Parameters:
  • browser
  • selector
Return:
  • elements — locator list.
  • length — number of matches.
Exceptions:
  • ElementNotFound when no elements are found.

playwright.get_inner_text

Get inner_text from locator.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
Return:
  • text
Exceptions:
  • ElementNotFound when locator is missing.

playwright.get_tabs

Return all tabs from current context.

Parameters:
  • browser
Return:
  • tabs — list with title and url.
  • count

playwright.get_text

Get text_content from locator.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
Return:
  • text
Exceptions:
  • ElementNotFound when locator is missing.

playwright.get_title

Get current page title.

Parameters:
  • browser
Return:
  • title

playwright.get_url

Get current page URL.

Parameters:
  • browser
Return:
  • url

playwright.handle_dialog

Register dialog handler (accept or dismiss).

Parameters:
  • browser
  • action (optional, default accept)
  • prompt_text (optional)
Return:
  • no return keys.
Exceptions:
  • ValueError when action is invalid.

playwright.hover

Hover over locator.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
  • force (optional, default False)
  • modifiers (optional)
  • position (optional)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.is_visible

Check locator visibility.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 5000)
Return:
  • is_visible
Exceptions:
  • ElementNotFound when locator is missing.

playwright.locator

Locate element by CSS/XPath selector.

Parameters:
  • browser
  • selector
  • index (optional) — when provided uses locator.nth(index).
Return:
  • locator
Exceptions:
  • ValueError when index < 0.

playwright.mock_api

Convenience wrapper around playwright.route for mocked fulfill response.

Parameters:
  • browser
  • url_pattern
  • response_body (optional)
  • response_json (optional)
  • status (optional, default 200)
  • headers (optional)
Return:
  • same return as playwright.route (no return keys).

playwright.navigate

Navigate page to a new URL.

Parameters:
  • browser
  • url
  • timeout (optional, default 30000)
  • wait_until (optional, default load) — load, domcontentloaded, networkidle, commit.
Return:
  • no return keys.

playwright.new_tab

Open new tab and optionally navigate to URL.

Parameters:
  • browser
  • url (optional)
Return:
  • page — new page identifier.

playwright.open

Open browser/context/page and navigate to URL.

Parameters:
  • url — initial URL.
  • headless (optional, default False) — run browser without UI.
  • browser_type (optional, default chromium) — chromium, firefox, webkit.
  • channel (optional) — Chromium channel (chrome, msedge, etc.).
  • timeout (optional, default 30000) — navigation timeout in ms.
  • viewport_width / viewport_height (optional, default 1280 / 720) — viewport size. Ignored when maximize=True.
  • maximize (optional, default False) — open the window using the native maximized size; mutually exclusive with viewport_width/viewport_height.
  • locale, timezone_id, user_agent (optional) — context options.
  • incognito (optional, default True) — compatibility signature.
  • downloads_path (optional) — directory where downloads are persisted. When omitted defaults to <assets_path>/downloads (or <MARVIN_HOME>/temp/downloads as a fallback).
Return:
  • browser — metadata dict with engine, browser_type, channel, headless, incognito, downloads_path.
Exceptions:
  • ImportError when Playwright is not installed.
  • ValueError when browser_type is invalid.
  • When the browser is opened via chrome.open, a global context-level download listener is attached and persists each download under downloads_path automatically. The listener resolves UUID/no-extension suggested filenames using URL hints and magic-byte detection, and avoids silent overwrites by appending a numeric suffix (e.g. fatura.zipfatura_2.zip when fatura.zip already exists). Pure playwright.open users do not get this listener; use playwright.wait_for_download / playwright.save_download instead.

playwright.press_key

Press key on locator.

Parameters:
  • browser
  • locator (required)
  • key (optional, default Enter)
  • timeout (optional, default 30000)
  • delay (optional, default 0)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.route

Register network route handler.

Parameters:
  • browser
  • url_pattern
  • handler_type (optional, default fulfill) — fulfill, continue, abort
  • body (optional)
  • status (optional, default 200)
  • headers (optional)
  • json_data (optional)
Return:
  • no return keys.
Exceptions:
  • ValueError when handler_type is invalid.

playwright.save_download

Save download to explicit path.

Parameters:
  • browser
  • download_info (optional)
  • save_path (required)
Return:
  • saved_path
Exceptions:
  • ValueError when save_path is missing.

playwright.screenshot

Capture screenshot from page or locator.

Parameters:
  • browser
  • path (optional)
  • full_page (optional, default False)
  • timeout (optional, default 30000)
  • locator (optional)
  • type (optional, default png)
  • quality (optional)
Return:
  • screenshot — bytes when path is not provided.
  • or no return keys when saved directly to file.

playwright.scroll_into_view

Scroll locator into view when needed.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.select_option

Select <option> by value, label, or index.

Parameters:
  • browser
  • locator (required)
  • value (optional)
  • label (optional)
  • index (optional)
  • timeout (optional, default 30000)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.
  • ValueError when no criterion is provided.

playwright.select_tab

Select tab by index, URL fragment, or title fragment.

Parameters:
  • browser
  • tab_index (optional)
  • tab_url (optional)
  • tab_title (optional)
Return:
  • page — selected page identifier.
Exceptions:
  • ElementNotFound when no tab matches criteria.

playwright.type_text

Type text character-by-character.

Parameters:
  • browser
  • locator (required)
  • text (optional, default empty string)
  • delay (optional, default 0)
  • timeout (optional, default 30000)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.uncheck

Uncheck checkbox.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
  • force (optional, default False)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.wait_for_download

Wait for download and save file.

Parameters:
  • browser
  • timeout (optional, default 30000)
  • save_path (optional)
Return:
  • download
  • download_path
  • suggested_filename
  • url

playwright.wait_for_element

Wait for locator state.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
  • state (optional, default visible) — visible, hidden, attached, detached.
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.
  • ValueError when state is invalid.

playwright.wait_for_element_hide

Wait until locator becomes hidden.

Parameters:
  • browser
  • locator (required)
  • timeout (optional, default 30000)
Return:
  • no return keys.
Exceptions:
  • ElementNotFound when locator is missing.

playwright.wait_for_navigation

Wait for navigation/load state and optional URL match.

Parameters:
  • browser
  • timeout (optional, default 30000)
  • url (optional)
  • wait_until (optional, default load)
Return:
  • no return keys.

playwright.wait_for_url

Wait until page URL matches pattern.

Parameters:
  • browser
  • url_pattern
  • timeout (optional, default 30000)
Return:
  • no return keys.

playwright.wait_load

Wait for page load state.

Parameters:
  • browser
  • timeout (optional, default 60000)
  • state (optional, default load) — load, domcontentloaded, networkidle.
Return:
  • no return keys.