Skip to content

Electron keyword reference

Electron library is a Robot Framework library for testing Electron applications.

It is built on the Browser library: its keywords, such as Click and Get Text, act on the windows of an application. Import Electron instead of Browser. The library hides Browser’s keywords for browsers and contexts, see Browser, Context and Page. Guides and examples are on the documentation site.

Start Electron Application starts an application and waits for its first window. Pass the application’s executable, or for an application that the plain Electron binary runs, the Electron executable and the application folder in args. The library downloads nothing: the npm package electron, for example, brings an Electron release, and require('electron') returns its executable.

${app} ${page} = `Start Electron Application` /opt/my-app/my-app
`Get Title` == My App
`Click` text=Settings

Close Electron Application ends an application. Automatic closing ends it with the test or suite that started it, see Automatic page and context closing.

Each window of an application is a page for Browser keywords, see Windows and pages.

Several applications can be open at once. Switch Electron Application makes another one the active application, and Get Electron Application Ids returns their ids.

Browser keywords reach the windows, but not the application’s main process. Evaluate In Main Process runs a JavaScript function there, for example to replace a native dialog or click a menu item. Set Window Size, Maximize Window and the other window keywords size windows and change their state, see Windows and pages.

Start Electron Application takes some options of the Browser library’s New Context: color_scheme, locale, timezone_id and bypass_csp. They apply from the start, so another value means starting the application again.

Start Electron Application records a video of the windows with record_video, a Playwright trace with tracing, and the network traffic of the windows with record_har. They are saved when the application closes.

The Browser library organises web pages in browsers, contexts and pages, see Browser, Context and Page in its documentation. An application maps onto them as follows:

  • An application is a browser of its own with exactly one context. The id that Start Electron Application returns is the application id.
  • Each window of the application is a page, and so is each \<webview> and WebContentsView. Switch Page and Get Page Ids work on all of them, Get Window Ids lists only the windows, see Windows and pages. Close Page closes windows and the pages of a WebContentsView. On the page of a \<webview>, it waits forever, so a test removes the \<webview> element from its page instead.

The library hides the Browser keywords for browsers and contexts, and those that cannot work on an application:

Browser keyword Here Why
New Browser, New Persistent Context, Open Browser Start Electron Application A test starts an application.
Close Browser, Close Context Close Electron Application The application ends with its only context.
Switch Browser Switch Electron Application Several applications can be open at once.
Get Browser Ids Get Electron Application Ids It returns the ids of the open applications.
Get Browser Catalog Get Electron Application Catalog It leaves out the context level.
New Context, Switch Context, Get Context Ids - An application has exactly one context.
New Page - The application opens its windows itself.
Launch Browser Server, Close Browser Server, Connect To Browser - For browsers only.
Get Device, Get Devices - Devices are options for New Context.
Crawl Site - It opens pages of its own.
Set Storage State - It needs a page of its own to write the storage.
Tap - Touch input is not enabled for applications.
Save Page As Pdf - Electron does not provide Chromium’s PDF printing over the DevTools protocol.

A test that needs a web browser as well imports the Browser library beside this one and calls the keywords that both libraries have with the library name, for example Browser.New Page.

Each window of an application is a page, and so is each \<webview> and WebContentsView that it shows. After Start Electron Application, the first window is the active page. Switch Window makes the page of another window the active page, best by the window’s title, because it waits until a window shows it. Get Electron Application Catalog lists all pages with their titles, and Switch Page selects any of them, also a \<webview> or WebContentsView.

Get Window Ids and Get Window Titles list only the windows. The keywords that act on a window take it in one of these forms:

Form Window
title=\<title> The window that shows this title, exactly as Get Window Titles returns it.
title=/\<pattern>/\<flags> The window whose title matches this JavaScript regular expression, in the form of Browser’s text= selector, for example title=/^Settings/i.
window=\<n> The window with this id from Get Window Ids. The bare number works as well, because Robot Framework reads window=2 as the named argument window with the value 2.
none The window that shows the active page, which for a \<webview> or WebContentsView is around it.

For a title or an expression, the keywords wait up to the library timeout until exactly one window matches, so a test can name a window that is still opening. Window ids are valid while the application runs and unique only within it, so get them again after Switch Electron Application.

Selectors work as in the Browser library, see Finding elements in its documentation. In an application:

  • CSS, id= and text= find elements in open shadow roots, and >>> reaches into iframes.
  • >>> does not reach into a \<webview>, which is not an iframe. Switch to the page of the \<webview> instead.

Keywords such as Get Text take an assertion operator and an expected value, and retry until the assertion holds or the timeout has passed, see Assertions in the Browser library’s documentation.

Browser keywords wait until their elements are ready, see Implicit waiting in the Browser library’s documentation. Set Browser Timeout changes how long.

Keywords that change a setting, such as Set Browser Timeout, take a scope that says how long the setting lasts, see Scope Setting in the Browser library’s documentation.

An application ends with the test or suite that started it, as the Browser library closes browsers and contexts, see Automatic page and context closing in its documentation. Close Electron Application ends it earlier.


*_
🏷auto_closing_level : AutoClosingLevel = TEST
🏷auto_delete_passed_tracing : bool = ${False}
🏷enable_playwright_debug : PlaywrightLogTypes | bool = library
🏷enable_presenter_mode : HighLightElement | bool = ${False}
🏷external_browser_executable : dict[SupportedBrowsers, str] | None = ${None}
🏷highlight_on_failure : bool = ${False}
🏷jsextension : list[str] | str | None = ${None}
🏷language : str | None = ${None}
🏷playwright_process_host : str | None = ${None}
🏷playwright_process_port : int | None = ${None}
🏷plugins : list[str] | str | None = ${None}
🏷retry_assertions_for : timedelta = 0:00:01
🏷run_on_failure : str = Take Screenshot \ fail-screenshot-{index}
🏷selector_prefix : str | None = ${None}
🏷show_keyword_call_banner : bool | None = ${None}
🏷strict : bool = ${True}
🏷timeout : timedelta = 0:00:10
🏷tracing_group_mode : TracingGroupMode = Full

Electron library takes the same import arguments as the Browser library, described under Importing in its documentation.

They configure the Browser keywords, for example their timeout or presenter mode, and apply to the windows of applications as to any other page. Arguments that are about browsers, such as external_browser_executable, have no effect on applications. All arguments are named arguments.

Example:

Library Electron timeout=20s enable_presenter_mode=True

name : str Name of the cookie.
value : str Given value for the cookie.
url : str | None = ${None} Given url for the cookie. Defaults to None. Either url or the domain / path pair must be set, but not both.
domain : str | None = ${None} Given domain for the cookie. Defaults to None. Either url or the domain / path pair must be set, but not both.
path : str | None = ${None} Given path for the cookie. Defaults to None. Either url or the domain / path pair must be set, but not both.
expires : str | datetime | None = ${None} Given expiry for the cookie. Can be a date, a unix time or a datetime object. Supports the same formats as the DateTime library or an epoch timestamp. Example: 2027-09-28 16:21:35
httpOnly : bool | None = ${None} Sets the httpOnly token.
secure : bool | None = ${None} Sets the secure token.
sameSite : CookieSameSite | None = ${None} Sets the sameSite mode. Can be Strict, Lax or None.

Tags:

  • BrowserControl
  • Setter

Adds a cookie to the currently active browser context.

Example:

`Add Cookie` foo bar http://address.com/path/to/site # Using url argument.
`Add Cookie` foo bar domain=example.com path=/foo/bar # Using domain and path arguments.
`Add Cookie` foo bar http://address.com/path/to/site expires=2027-09-28 16:21:35 # Expires as timestamp.
`Add Cookie` foo bar http://address.com/path/to/site expires=1822137695 # Expires as epoch seconds.

Comment >>


selector : str Is the selector to the element which indicates that the locator handler should be called.
click_selector : str Is the selector to the element to be clicked.
🏷noWaitAfter : bool = ${True} Defaults to True, which means that the overlay may stay visible after the handler has run. If set to False, Playwright waits until the overlay becomes hidden, and only then the library continues with the action/assertion that triggered the handler.
🏷times : int | None = ${None} Is how many times the locator handler is called. None, the default, means unlimited.
🏷click_clickCount : int = ${1} Is the number of times to click the element. Defaults to 1.
🏷click_delay : int = ${0} Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.
🏷click_force : bool = ${False} Whether to bypass checks and dispatch the event directly. Defaults to false.

Tags:

  • PageContent
  • Setter

Add a handler function which will activate when selector is visible and click.

The handler will click the element indicated by click_selector.

When testing a web page, sometimes unexpected overlays, for example an “Accept Cookies” dialog, might appear and block the interaction with the page, like the Click keyword. These overlays can be problematic to handle, because they might appear randomly in the page. This keyword allows to create an automatic method, which will close those overlays by clicking the element indicated by click_selector. The handler is activated when the element indicated by selector is visible. For further information, see Playwright’s addLocatorHandler method.

The arguments click_selector, click_clickCount, click_delay and click_force correspond to the arguments of the Click With Options keyword, but click_delay is given as a plain number of milliseconds. The selector, noWaitAfter and times are for the locator handler. The handler is tied to the active page, if there is need to add handler to another page, this keyword needs to be called separately for each page. If the times argument is set to a positive value, the locator handler is removed after the handler has been called the specified number of times.

Example add locator handler to click button with id=“ButtonInOverlay” when id=Overlay is visible:

`New Page` ${URL}
`Add Locator Handler Click` id=Overlay id=ButtonInOverlay # Add locator handler to page
`Type Text` id:username user # If element with id=Overlay appears, the handler will click the button id=ButtonInOverlay
`Type Text` id:password password # Or if overlay is visible here, then handler is called here
`Click` id:login
`Remove Locator Handler` id=Overlay # Removes the locator handler from page

selector : str Is the selector to the element which indicates that the locator handler should be called.
handler_spec : list[dict] Is a list of dictionaries which defines the actions to be performed.
noWaitAfter : bool = ${True} Defaults to True, which means that the overlay may stay visible after the handler has run. If set to False, Playwright waits until the overlay becomes hidden, and only then the library continues with the action/assertion that triggered the handler.
times : int | None = ${None} Is how many times the locator handler is called. None, the default, means unlimited.

Tags:

  • PageContent
  • Setter

Add a handler function which will activate when selector is visible and performs handler specification.

When the element indicated by selector is visible, the handler will perform the actions specified in the handler_spec.

The handler_spec is a list of dictionaries, where each dictionary defines one action. The dictionary must contain the key action which defines the action to be performed. The action can be one of the following: click, fill, check and uncheck. Action is also case insensitive. The dictionary must also contain the key selector which defines the element to be interacted with. The fill action must also contain the key value which defines the value to be filled in the element. For the other actions the key value must not be defined. Additional keys are passed to the action as keyword arguments. For example for the click action refer to Playwright’s documentation to see which options are possible.

The selectors in the handler_spec are not resolved in strict mode. If a selector matches more than one element, the first matching element is used. If an action in the handler fails, the error is only logged on the Browser library node side and the keyword which triggered the handler does not fail because of it.

The selector, noWaitAfter and times are for the locator handler method. The handler is tied to the active page, if there is need to add handler to another page, this keyword needs to be called separately for each page. If the times argument is set to a positive value, the locator handler is removed after the handler has been called the specified number of times.

Running the handler will alter your page state mid-test. For example it will change the currently focused element and move the mouse. Make sure that keywords that run after the handler are self-contained and do not rely on the focus and mouse state being unchanged.

Please note that the automatic argument conversion is not done for the handler_spec dictionary. This is because Robot Framework does not convert values inside the dictionary that are actually arguments to a separate Playwright API call. Therefore the user is responsible for converting the values to the correct type. For example if a timeout is needed, the value must be converted to a number on the Robot Framework test data side.

Example adds locator handler to fill input id=overlayInput with value “Hello” and click element id=OverlayCloseButton when id=Overlay is visible:

`New Page` ${URL}
VAR &{handler_spec_fill}
... action=Fill
... selector=id=overlayInput
... value=Hello
VAR &{handler_spec_click}
... action=click
... selector=id=OverlayCloseButton
`Add Locator Handler Custom`
... id=overlay
... [${handler_spec_fill}, ${handler_spec_click}]
`Type Text` id:username user # If element with id=overlay appears, the handler fills id=overlayInput and clicks id=OverlayCloseButton
`Type Text` id:password password # Or if overlay is visible here, then handler is called here
`Click` id:login

Example with click and different options and types:

VAR &{handler_spec}
... action=CLICK # Action is case insensitive
... selector=id=OverlayCloseButton
... button=left
... clickCount=${1}
... delay=${0.1}
... force=${True}
Add Locator Handler Custom id=overlay [${handler_spec}]

The keyword can only handle click, fill, check and uncheck Playwright API calls. If there is a need for more complex interactions, it is recommended to create a custom js extension to handle the interactions.

Example:

async function customLocatorHandler(locator, pageLocator, clickLocator, page) {
console.log("Adding custom locator handler for: " + locator);
const pageLocator = page.locator(locator).first();
await page.addLocatorHandler(
pageLocator,
async () => {
console.log("Handling custom locator: " + clickLocator);
// More complex interactions can be added here
await page.locator(clickLocator).click();
}
);
}
exports.__esModule = true;
exports.customLocatorHandler = customLocatorHandler;

content : str Raw CSS content to be injected into the current page.

Tags:

  • PageContent
  • Setter

Adds a <style type=“text/css”> tag with the content.

The tag is added to the currently active page and it is lost when the page is navigated to a new url.

Example:

`Add Style Tag` \#username_field:focus {background-color: aqua;}

Comment >>


time : timedelta The time to advance. Supports Robot Framework time format
advance_type : CLockAdvanceType = fast_forward The type of advance. Default is fast_forward.

Tags:

  • Clock
  • Setter

Advances the clock by a specified amount of time.

run_for advances the clock by firing all the time-related callbacks.

fast_forward advances the clock by jumping forward in time. It fires due timers at most once.


download : DownloadInfo | str A DownloadInfo object or id of the download to be canceled.

Tags:

  • BrowserControl
  • Setter

Cancels an active download.

Comment >>


selector : str Selector of the checkbox. See the Finding elements section for details about the selectors.
force : bool = ${False} Set to True to skip Playwright’s Actionability checks.

Tags:

  • PageContent
  • Setter

Checks the checkbox or selects radio button found by selector.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Does nothing if the element is already checked/selected.

Comment >>


Tags:

  • BrowserControl
  • Setter

Clears all permissions from the current context.

Comment >>


selector : str Selector of the text field. See the Finding elements section for details about the selectors.

Tags:

  • PageContent
  • Setter

Clears the text field found by selector.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Comment >>


selector : str Selector element to click. See the Finding elements section for details about the selectors.
button : MouseButton = left Mouse button to click with. One of left, middle or right. Defaults to left.

Tags:

  • PageContent
  • Setter

Simulates mouse click on the element found by selector.

This keyword clicks an element matching selector by performing the following steps:

  • Find an element matching the selector. If there is none, wait until a matching element is attached to the DOM.
  • Wait for actionability checks on the matched element. If the element is detached during the checks, the whole action is retried.
  • Scroll the element into view if needed.
  • Use Mouse Button to click in the center of the element.
  • Wait for initiated navigation to either succeed or fail.

Keyword uses strict mode, see Finding elements for more details about strict mode.

See Click With Options if you need modifiers, a click count, a click position or want to skip the actionability checks.

Example:

`Click` id=button_location
`Click` id=button_location left
`Click` id=button_location right

Comment >>


selector : str Selector element to click. See the Finding elements section for details about the selectors.
button : MouseButton = left Mouse button to click with. One of left, middle or right. Defaults to left.
*modifiers : KeyboardModifier Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used. Modifiers can be specified in any order, and multiple modifiers can be specified. Valid modifier keys are Alt, Control, ControlOrMeta, Meta and Shift. Due to the fact that the argument *modifiers is a positional only argument, all preceding keyword arguments have to be specified as positional arguments before *modifiers.
🏷clickCount : int = ${1} How many times the button is clicked. Defaults to 1.
🏷delay : timedelta | None = ${None} Time to wait between mouse-down and mouse-up. Defaults to no delay.
🏷force : bool = ${False} Set to True to skip Playwright’s Actionability checks (https://playwright.dev/docs/actionability). Defaults to False.
🏷noWaitAfter : bool = ${False} Deprecated. This option will default to true in the future. Actions that initiate navigation, are waiting for these navigation to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to False.
🏷position_x : float | None = ${None} A point to click relative to the top-left corner of element bounding-box. Only positive values within the bounding-box are allowed. Both values must be given, otherwise the position is ignored. If not specified, clicks to some visible point of the element.
🏷position_y : float | None = ${None} A point to click relative to the top-left corner of element bounding-box. Only positive values within the bounding-box are allowed. Both values must be given, otherwise the position is ignored. If not specified, clicks to some visible point of the element.
🏷trial : bool = ${False} When set, this method only performs the actionability checks and skips the action. Defaults to False. Useful to wait until the element is ready for the action without performing it.

Tags:

  • PageContent
  • Setter

Simulates mouse click on the element found by selector.

This keyword clicks an element matching selector by performing the following steps:

  • Find an element matching the selector. If there is none, wait until a matching element is attached to the DOM.
  • Wait for actionability checks on the matched element, unless the force option is set. If the element is detached during the checks, the whole action is retried.
  • Scroll the element into view if needed.
  • Use Mouse Button to click in the center of the element, or the specified position.
  • Wait for initiated navigation to either succeed or fail, unless the noWaitAfter option is set.

Arguments clickCount, delay, position_x, position_y, force, noWaitAfter and trial are named-only arguments and must be specified using their names.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example:

`Click With Options` id=button_location
`Click With Options` id=button_location trial=True
`Click With Options` \#clickWithOptions delay=100ms clickCount=2
`Click With Options` id=clickWithModifiers left Alt Meta Shift clickCount=1 force=True
`Click With Options` id=clickWithOptions right clickCount=2 force=True

Comment >>


application : SelectionType | str = CURRENT The application id that Start Electron Application returned. CURRENT ends the active application, ALL ends all applications.

Return Type: None

Ends an Electron application and removes it from the library state.

The keyword returns after the application process has exited. It also passes if the application has already quit on its own. The application that was active before becomes active again. Automatic closing ends applications as well, see Automatic page and context closing.

Example:

${app} ${_} = `Start Electron Application` /opt/my-app/my-app
`Close Electron Application` ${app}
`Close Electron Application` ALL

page : SelectionType | NewPageDetails | str = CURRENT Page to close. CURRENT selects the active page. ALL selects all pages. When a page id is provided, that page is closed.
context : SelectionType | str = CURRENT Context in which pages are closed. CURRENT selects the active context. ALL selects all contexts. When a context id is provided, pages of that context are closed. The contexts themselves are not closed.
browser : SelectionType | str = CURRENT Browser in which pages are closed. CURRENT selects the active browser. ALL selects all browsers. When a browser id is provided, pages of that browser are closed. The browsers themselves are not closed.
runBeforeUnload : bool = ${False} defines whether to run the before unload page handlers. Defaults to false.

Return Type: list[dict]

Tags:

  • BrowserControl
  • Setter

Closes the page in context in browser.

Defaults to current for all three. Active page is set to the page that was active before this one. See Browser, Context and Page for more information about Page and related concepts.

If a page id is given, the context and browser arguments are ignored and the page is searched from all open browsers. Likewise, if a context id is given, the browser argument is ignored.

Returns a list of dictionaries containing id, errors and console messages from the page.

Example:

`Close Page` # Closes current page, within the current context and browser
`Close Page` CURRENT CURRENT CURRENT # Closes current page, within the current context and browser
`Close Page` ALL ALL ALL # Closes all pages, within all contexts and browsers

Comment >>

In Electron applications:

Closes windows and the pages of a WebContentsView. On the page of a \<webview>, it waits forever: Electron destroys the contents of the \<webview>, but Chromium reports the page as closed only once the \<webview> element is gone. Remove the element instead:

`Evaluate JavaScript` id=guest (element) => element.remove()

An application has exactly one context, and browser takes an application id, see Browser, Context and Page.


rpId : str Relying party id (typically the site’s effective domain).
id_ : str | None = ${None} Base64url-encoded credential id. Auto-generated if omitted.
privateKey : Secret | str | None = ${None} Base64url-encoded PKCS#8 (DER) private key. Auto-generated if omitted.
publicKey : Secret | str | None = ${None} Base64url-encoded SPKI (DER) public key. Auto-generated if omitted.
userHandle : str | None = ${None} Base64url-encoded user handle. Auto-generated if omitted.

Tags:

  • Credential
  • Setter

Creates a credential with the given parameters.

Will always create and install the credential, even if the optional parameters are not provided. In this case Playwright will autogenerate the missing values.

The credential is created in the currently active context and it is used by all pages that are created from that context. There must be an open context, otherwise the keyword fails.

Because privateKey and publicKey are sensitive information, it is recommended to wrap their values in the Secret type. The Secret type requires Robot Framework 7.4 or newer. If you are using Robot Framework 7.3 or older, the keyword supports resolving privateKey and publicKey from Robot Framework variables and environment variables in the following ways. The keyword resolves the value from a Robot Framework variable internally, when the variable is prefixed with $, without the curly braces. Example: $publicKey will resolve to the ${publicKey} Robot Framework variable.

If the privateKey or publicKey value is prefixed with %, the library will resolve the corresponding environment variable. Example: %PUBLICKEY will resolve to the %{PUBLICKEY} environment variable.

Plain values are not accepted. If the given privateKey or publicKey is not a Secret and does not resolve to another value, the keyword fails with an error stating that direct assignment of values or variables is not allowed.

Example:

`New Context`
${credentials} = Get Credentials # This is a helper keyword that returns a dictionary with the required credential parameters.
`Create Credential`
... rpId=${DOMAIN_NAME}
... id_=${credentials["id"]}
... privateKey=${credentials["privateKey"]} # This should be a Secret type or a string starting with $ which resolves to a Robot Framework variable.
... publicKey=${credentials["publicKey"]} # This should be a Secret type or a string starting with $ which resolves to a Robot Framework variable.
... userHandle=${credentials["userHandle"]}
`New Page` ${SUT_URL}
`Click` id=login
`Get Text` id=status == Success

Tags:

  • BrowserControl
  • Setter

Deletes all cookies from the currently active browser context.

Comment >>


id_ : str Base64url-encoded credential id.

Tags:

  • Credential
  • Setter

Deletes the credential with the given id.

Deleting a credential which does not exist does not fail. There must be an open context, otherwise the keyword fails.

Example:

`Delete Credential` id_=${CREDENTIAL_ID}

selector : str Selector of the select tag. See the Finding elements section for details about the selectors.

Tags:

  • PageContent
  • Setter

Deselects all options from select element found by selector.

If you just want to select one or more specific options and currently more options are selected, use Select Options By keyword with the options to be selected in the end.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Comment >>


url : str URL to the file that shall be downloaded.
saveAs : str = ${EMPTY} Path where the file shall be saved persistently. If empty, generated unique path (GUID) is used and file is deleted when the context is closed.
wait_for_finished : bool = ${True} If set to False keyword returns immediately after the download has started. Defaults to True.
download_timeout : timedelta | None = ${None} Maximum total time for the file to be fetched and saved. If the file is not fetched within this time, the keyword fails. If it is fetched but not saved, the download is cancelled and the keyword fails. If wait_for_finished is False, only the fetching is limited. If not set, the file must be fetched within the browser timeout, see Set Browser Timeout, and there is no limit for saving it.

Return Type: DownloadInfo

Tags:

  • Page Content

Download given url content.

Keyword returns dictionary of type DownloadInfo.

Example:

{
"saveAs": "/tmp/robotframework-browser/downloads/2f1b3b7c-1b1b-4b1b-9b1b-1b1b1b1b1b1b",
"suggestedFilename": "downloaded_file.txt",
"state": "finished",
"downloadID": None,
}

When wait_for_finished is False, the returned dictionary has an empty saveAs, the state is in_progress and downloadID contains the id of the download. The download can then be followed with the Get Download State keyword, which also saves the file to saveAs when the download is finished.

If the download should be started by an interaction with an element on the page, Promise To Wait For Download keyword may be a better choice.

The keyword New Browser has a downloadsPath setting which can be used to set the default download directory. If saveAs is set to a relative path, the file will be saved relative to the browser’s downloadsPath setting or if that is not set, relative to the Playwright’s working directory. If saveAs is set to an absolute path, the file will be saved to that absolute path independent of downloadsPath.

To enable downloads context’s acceptDownloads needs to be true, otherwise the keyword fails. This keyword requires that there is currently an open page and that the page has been navigated to an url, downloading from about:blank fails. The download is done by a fetch call inside the page and therefore it uses the current page’s local state (cookies, sessionstorage, localstorage) to avoid authentication problems. Because of that, a relative url is resolved against the current page url and the page’s cross-origin restrictions apply.

The whole file is fetched before the browser reports the download as started. Set download_timeout when fetching the file can take longer than the browser timeout, for example with large files or slow servers.

Example:

${file_object}= `Download` ${url} download_timeout=2 minutes
${actual_size}= Get File Size ${file_object.saveAs}

Example 2:

${href}= `Get Property` text="Download File" href
`Download` ${href} saveAs=${OUTPUT DIR}/downloads/downloaded_file.txt
File Should Exist ${OUTPUT DIR}/downloads/downloaded_file.txt

Comment >>


selector_from : str Identifies the element whose center is the start-point.
selector_to : str Identifies the element whose center is the end-point.
steps : int = ${1} Defines how many intermediate mouse move events are sent. Often it is necessary to send more than one intermediate event to get the desired result. Defaults to 1.

Tags:

  • PageContent
  • Setter

Executes a Drag&Drop operation from the element selected by selector_from to the element selected by selector_to.

See the Finding elements section for details about the selectors.

First it moves the mouse to the start-point, then presses the left mouse button, then moves to the end-point in specified number of steps, then releases the mouse button.

Start- and end-point are defined by the center of the elements’ bounding box.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example

`Drag And Drop` "Circle" "Goal"

Comment >>


from_x : float Identify the start-point on page.
from_y : float Identify the start-point on page.
to_x : float Identify the end-point.
to_y : float Identify the end-point.
steps : int = ${1} Defines how many intermediate mouse move events are sent. Often it is necessary to send more than one intermediate event to get the desired result. Defaults to 1.

Tags:

  • PageContent
  • Setter

Executes a Drag&Drop operation from a coordinate to another coordinate.

First it moves the mouse to the start-point, then presses the left mouse button, then moves to the end-point in specified number of steps, then releases the mouse button.

Start- and end-point are defined by x and y coordinates relative to the top left corner of the pages viewport.

Example:

`Drag And Drop By Coordinates`
... from_x=30 from_y=30
... to_x=10 to_y=10 steps=20

Comment >>


selector_from : str Identifies the element whose center is the start-point.
x : float = ${0.0} Identify the end-point, which is relative to the start-point.
y : float = ${0.0} Identify the end-point, which is relative to the start-point.
steps : int = ${1} Defines how many intermediate mouse move events are sent. Often it is necessary to send more than one intermediate event to get the desired result. Defaults to 1.

Tags:

  • PageContent
  • Setter

Executes a Drag&Drop operation from the element selected by selector_from to coordinates relative to the center of that element.

This keyword can be handy to simulate swipe actions.

See the Finding elements section for details about the selectors.

First it moves the mouse to the start-point (center of the bounding box), then presses the left mouse button, then moves to the relative position with the given intermediate steps, then releases the mouse button.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example

`Drag And Drop Relative To` "Circle" -20 0 # Slides the element 20 pixels to the left

Comment >>


Eat all cookies for all easter.

Comment >>


colorScheme : ColorScheme | None = ${None} Emulates the prefers-color-scheme media feature, supported values are light and dark. Passing null disables color scheme emulation. no-preference is deprecated.
forcedColors : ForcedColors | NotSet = not_set Emulates the forced-colors media feature, supported values are active and none. Passing null disables forced colors emulation.
media : Media | None = ${None} Changes the CSS media type of the page. The only allowed values are screen, print and null. Passing null disables CSS media emulation.
reducedMotion : ReducedMotion | None = ${None} Emulates the prefers-reduced-motion media feature, supported values are reduce and no-preference. Passing null disables reduced motion emulation.

Return Type: dict

Tags:

  • PageContent
  • Setter

Changes the CSS media type.

It changes the CSS media type through the media argument, and/or the prefers-color-scheme media feature, using the colorScheme argument. This is useful to render the page in the correct format before using the Save Page As Pdf keyword.

Arguments which are left to their default value are not sent to Playwright at all and therefore the corresponding emulation is left unchanged.


function : str A JavaScript function as text, or its first line. The function gets three parameters: the electron module, arg, and window, the BrowserWindow that shows the active page. For a \<webview> or a WebContentsView, that is the window they are shown in. window is null if the active page is not one of the application’s, for example while another application is active. The function may return a promise.
*lines : str Further lines of the function. They are joined to function with line breaks, so that a function can span several cells with ....
🏷arg : Any = ${None} A JSON-serialisable value that the function gets.
🏷application : SelectionType | str = CURRENT CURRENT for the active application, or an application id that Start Electron Application returned.

Return Type: Any — The function’s result, which must be JSON-serialisable. Objects of the main process, such as a BrowserWindow, cannot be returned. None if the function returns nothing.

Raises:

  • AssertionError: No application is open, the id is not an application started by Start Electron Application, or the function throws an error.

Runs a JavaScript function in the main process of an Electron application and returns its result.

Browser keywords reach the application’s windows, but not its main process. There, a test can replace a native dialog before the application opens it, focus a window, click a menu item, or read the application’s state. The window keywords, such as Set Window Size and Maximize Window, size windows and change their state. The function runs as with Playwright’s electronApplication.evaluate.

Example:

${name} = `Evaluate In Main Process` ({ app }) => app.getName()
`Evaluate In Main Process` ({ dialog }, path) => {
... dialog.showOpenDialog = async () => ({ canceled: false, filePaths: [path] });
... }
... arg=${EXECDIR}/data/report.csv
${focused} = `Evaluate In Main Process` (electron, arg, window) => window.isFocused()

selector : str | None = ${None} Selector to resolve and pass to the JavaScript function. This will be the first argument the function receives if not ${None}. selector is optional and can be omitted. If given a selector, a function is necessary, with an argument to capture the element. For example (element) => document.activeElement === element. See the Finding elements section for details about the selectors.
*function : str A valid javascript function or a javascript function body. These arguments can be used to write readable multiline JavaScript.
🏷arg : Any = ${None} an additional argument that can be handed over to the JavaScript function. It is the second argument of the function when a selector is given, otherwise the first one. This argument must be JSON serializable. ElementHandles are not supported.
🏷all_elements : bool = ${False} defines if only the single element found by selector is handed over to the function or if set to True all found elements are handed over as array.

Return Type: Any

Tags:

  • Getter
  • PageContent
  • Setter

Executes the given JavaScript in the browser page.

The JavaScript is evaluated in the context of the page, not in the Node process of the library. Therefore browser globals like window and document are available, but Robot Framework variables and Python objects are not. Only arg and the resolved element(s) are passed into the page.

The value returned by the JavaScript is transferred as JSON and must therefore be JSON serializable. DOM nodes and other non serializable objects can not be returned. If the JavaScript does not return anything, the keyword returns an empty string.

Example with all_elements=True:

${texts}= Evaluate JavaScript button
... (elements, arg) => {
... let text = []
... for (e of elements) {
... console.log(e.innerText)
... text.push(e.innerText)
... }
... text.push(arg)
... return text
... }
... all_elements=True
... arg=Just another Text

Keyword uses strict mode only if all_elements is False. See Finding elements for more details about strict mode.

Usage examples.

Comment >>


selector : str Selector of the text field. See the Finding elements section for details about the selectors.
secret : str | Secret The secret string that should be filled into the text field. Supports Robot Framework 7.4 Secret type as normal variable (with curly braces). Also environment variable name with % prefix or a local variable with $ prefix that has the secret text value (without curly braces).
force : bool = ${False} Set to True to skip Playwright’s Actionability checks.

Tags:

  • PageContent
  • Setter

Fills the given secret into the text field found by selector.

This keyword does not log the secret in Robot Framework logs, but if Playwright debug logs are enabled, the secret will be visible as plain text in the Playwright debug logs, regardless of the Robot Framework log level or how secret is resolved.

This keyword supports Robot Framework 7.4 Secret variable type, which is the recommended way if you are using Robot Framework 7.4 or newer.

For older Robot Framework versions the keyword supports resolving secrets from environment variables and Robot Framework variables in the following ways. The keyword resolves the secret from a Robot Framework variable internally, when the secret variable is prefixed with $, without the curly braces. Example: $Password will resolve to the ${Password} Robot Framework variable.

If the secret variable is prefixed with %, the library will resolve the corresponding environment variable. Example: %ENV_PWD will resolve to the %{ENV_PWD} environment variable.

Using normal Robot Framework variables like ${password}, which are not Secret type variables, will not work!

Normal plain text will not work. If you want to use plain text, use the Fill Text keyword instead.

This keyword also works with a cryptographic cipher text that has been encrypted by CryptoLibrary. See CryptoLibrary for more details.

Keyword uses strict mode, see Finding elements for more details about strict mode.

See Fill Text for other details.

Example:

`Fill Secret` input#username_field ${username} # Keyword resolves variable value from Robot Framework Secret type variables
`Fill Secret` input#username_field $username # Keyword resolves variable value from Robot Framework variables
`Fill Secret` input#username_field %username # Keyword resolves variable value from environment variables

Comment >>


selector : str Selector of the text field. See the Finding elements section for details about the selectors.
txt : str Text for the text field.
force : bool = ${False} Set to True to skip Playwright’s Actionability checks.

Tags:

  • PageContent
  • Setter

Clears and fills the given txt into the text field found by selector.

This keyword waits for an element matching the selector to appear, waits for actionability checks, focuses the element, fills it and triggers an input event after filling.

If the element matching the selector is not an <input>, <textarea> or [contenteditable] element, this keyword fails. Note that you can pass an empty string as txt to clear the input field.

Keyword uses strict mode, see Finding elements for more details about strict mode.

See Type Text for emulating typing text character by character.

Example:

`Fill Text` css=input#username_field username

Comment >>


selector : str Selector of the element. See the Finding elements section for details about the selectors.

Tags:

  • PageContent
  • Setter

Moves focus on to the element found by selector.

Keyword uses strict mode, see Finding elements for more details about strict mode.

If there is no element matching the selector, the keyword waits until a matching element appears in the DOM. It fails if the element does not appear within the library timeout, which is 10 seconds by default and can be changed with Set Browser Timeout.

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
return_type : AriaSnapshotReturnType = yaml Defines the return type. Possible values are yaml (default), dict and parsed. If yaml is selected, the returned value is a string in YAML format. If dict is selected, the returned value is a dictionary. If parsed is selected, the returned value is a tree of node dictionaries.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.
🏷mode : AriaSnapshotMode = default Defines the snapshot mode. Possible values are default (default) and ai. See AriaSnapshotMode for more details.
🏷depth : int | None = ${None} Limits the snapshot to the given number of tree levels. Must be a positive integer. Defaults to None, which does not limit the depth.
🏷boxes : bool = ${False} If True, the bounding box of each element is appended to its line as [box=x,y,width,height]. Coordinates are relative to the viewport, in CSS pixels. Defaults to False.

Return Type: str | dict | list | tuple

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the aria snapshot of the element found by selector. See AriaSnapshotReturnType for more details and examples.

Keyword uses strict mode, see Finding elements for more details about strict mode.

With mode=ai the snapshot is optimized for AI consumption: it contains element references like [ref=e2] and the content of iframes inside the element. It also does not wait for a matching element, but fails immediately when no element matches, instead of failing with a timeout like the default mode does.

With return_type=dict the YAML returned by Playwright is loaded as is. The [ref=...] and [box=...] annotations are therefore part of the dictionary keys, not separate entries. Use return_type=parsed to get them as separate values of each node.

Optionally asserts that the snapshot matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Example:

${aria} = `Get Aria Snapshot` id=main # returns YAML string
Log Many ${aria}
${aria_dict} = `Get Aria Snapshot` id=main dict # returns dictionary
Log Many ${aria_dict}

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
attribute : str Requested attribute name.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.

Return Type: str | tuple | dict | None

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the HTML attribute of the element found by selector.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the attribute value matches the expected value. See Assertions for further details for the assertion arguments. By default assertion is not done.

When an attribute is selected that is not present and no assertion operator is set, the keyword fails. If an assertion operator is set and the attribute is not present, the returned value is None. This can be used to check the presence or the absence of an attribute.

Example Element:

<button class="login button active" id="enabled_button" something>Login</button>

Example Code:

`Get Attribute` id=enabled_button disabled # FAIL => "Attribute 'disabled' not found!"
`Get Attribute` id=enabled_button disabled == ${None} # PASS => returns: None
`Get Attribute` id=enabled_button something evaluate value is not None # PASS => returns: True
`Get Attribute` id=enabled_button disabled evaluate value is None # PASS => returns: True

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
*assertion_expected Expected value for the state
🏷message : str | None = ${None} overrides the default error message for assertion.

Return Type: list[str]

Tags:

  • Assertion
  • Getter
  • PageContent

Returns all HTML attribute names of an element as a list.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the attribute names match the expected values. See Assertions for further details for the assertion arguments. By default assertion is not done.

Available assertions:

  • == , != and contains / *= can work with multiple values
  • validate and evaluate only accept one single expected value

Other operators are not allowed.

Example:

`Get Attribute Names` [name="readonly_input"] == type name value readonly # Has exactly these attribute names.
`Get Attribute Names` [name="readonly_input"] contains disabled # Contains at least this attribute name.

Comment >>


selector : str Selector from which the bounding box shall be retrieved. See the Finding elements section for details about the selectors.
key : BoundingBoxFields = ALL Optionally filters the returned values. If keys is set to ALL (default) it will return the BoundingBox as Dictionary, otherwise it will just return the single value selected by the key. Note: If a single value is retrieved, an assertion does not need a validate combined with a cast of value.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.
🏷allow_hidden : bool = ${False} (named only) If True, hidden elements are not causing a failure and will return None. Otherwise a hidden element will fail. Defaults to False.

Return Type: BoundingBox | float | int | None

Tags:

  • Assertion
  • Getter
  • PageContent

Gets elements size and location as an object {x: float, y: float, width: float, height: float}.

Alternatively you can select a single attribute of the bounding box by setting the key argument.

If an element is hidden and has no bounding box, the keyword will fail. Depending on the method used to make an element invisible, an element might still have a bounding box which can be retrieved. To allow also hidden elements without a bounding box, set allow_hidden to True, which results in a return value of None in case of no bounding box.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the value matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Example use:

${bounding_box}= `Get BoundingBox` id=element # unfiltered
Log ${bounding_box} # {'x': 559.09375, 'y': 75.5, 'width': 188.796875, 'height': 18}
${x}= `Get BoundingBox` id=element x # filtered
Log X: ${x} # X: 559.09375
# Assertions:
`Get BoundingBox` id=element width > 180
`Get BoundingBox` id=element ALL validate value['x'] > value['y']*2

Comment >>


selector : str Selector which shall be examined. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} == and != and equivalent are allowed on boolean values. Other operators are not accepted.
assertion_expected : bool | str = Unchecked Boolean value of expected state. Strings are interpreted as booleans. All strings are ${True} except the following: FALSE, NO, OFF, 0, UNCHECKED, NONE, ${EMPTY} (case-insensitive). Defaults to UNCHECKED.
message : str | None = ${None} overrides the default error message for assertion.

Return Type: bool

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the state of the checkbox found by selector.

Optionally asserts that the state matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

  • CHECKED => True
  • UNCHECKED => False

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example:

`Get Checkbox State` [name=can_send_email] == checked

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
*assertion_expected Expected values for the state
🏷message : str | None = ${None} overrides the default error message for assertion.

Return Type: list[str]

Tags:

  • Assertion
  • Getter
  • PageContent

Returns all classes of an element as a list.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the value matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Available assertions:

  • == , != and contains / *= can work with multiple values
  • validate and evaluate only accept one single expected value

Other operators are not allowed.

Example:

`Get Classes` id=draggable == react-draggable box # Element has exactly these class names.
`Get Classes` id=draggable validate "react-draggable-dragged" not in value # Element does not contain react-draggable-dragged class.

Comment >>


selector : str | None = ${None} Optional selector from which the client size shall be retrieved. If no selector is given the client size of the page itself is used (document.scrollingElement). See the Finding elements section for details about the selectors.
key : SizeFields = ALL Optionally filters the returned values. If keys is set to ALL (default) it will return the client size as dictionary, otherwise it will just return the single value selected by the key.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.

Return Type: Dimensions | float

Tags:

  • Assertion
  • Getter
  • PageContent

Gets elements or pages client size (clientHeight, clientWidth) as object {width: float, height: float}.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the value matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

See Get BoundingBox or Get Scroll Size for examples.

Comment >>


assertion_operator : AssertionOperator | None = ${None} Optional assertion operator. See Assertions for more information.
assertion_expected : Any | None = ${None} Optional expected value. See Assertions for more information.
message : str | None = ${None} Optional custom message to use on failure. See Assertions for more information.
🏷full : bool = ${False} If true, returns the full console log. If false, returns only new entries that were added since last time.
🏷last : int | timedelta | None = ${None} If set, returns only the last n entries. Can be an integer for the number of entries or a time period in Robot Framework time format.

Return Type: list[dict]

Tags:

  • Assertion
  • BrowserControl
  • Getter

Returns the console log of the active page.

If assertions are used and fail, this keyword will fail immediately without retrying.

The returned data is a list of log messages.

A log message is a dictionary with the following structure:

[{
"type": str,
"text": str,
"location": {
"url": str,
"lineNumber": int,
"columnNumber": int
},
"time": str
}]

Example:

[{
'type': 'log',
'text': 'Stuff loaded...',
'location': {
'url': 'https://example.com/js/chunk-769742de.6a462276.js',
'lineNumber': 60,
'columnNumber': 63771
},
'time': '2023-02-05T17:42:52.064Z'
}]

Keys:

Key Description
type One of the following values: log, debug, info, error, warning, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd
text The text of the console message.
location.url The URL of the resource that generated this message.
location.lineNumber The line number in the resource that generated this message (0-based).
location.columnNumber The column number in the resource that generated this message (0-based).
time The timestamp of the log message as ISO 8601 string.

Comment >>


cookie : str Name of the cookie to be retrieved.
return_type : CookieType = dictionary Type of the return value. Can be either dictionary or string. Defaults to dictionary.

Return Type: DotDict | str

Tags:

  • BrowserControl
  • Getter

Returns information about the cookie named cookie as a Robot Framework dot dictionary or a string.

If return_type is dictionary or dict, then the keyword returns a Robot Framework dot dictionary. The dictionary contains all key value pairs of the cookie. If return_type is string or str, then the keyword returns the cookie as a string in format: name1=value1. The return value contains only the name and value keys of the cookie.

If no cookie is found with the given name, the keyword fails. The cookie dictionary contains details about the cookie. Keys available in the dictionary are documented in the table below.

Value Explanation
name The name of the cookie.
value Value of the cookie.
domain Specifies which hosts are allowed to receive the cookie.
path Indicates a URL path that must exist in the requested URL, for example /.
expires Lifetime of a cookie. Returned as a datetime object or None if no valid time is received.
httpOnly When true, the cookie is not accessible via JavaScript.
secure When true, the cookie is only used with HTTPS connections.
sameSite Attribute that lets servers require that a cookie shouldn’t be sent with cross-origin requests.

See playwright documentation for details about each attribute.

Example:

${cookie}= `Get Cookie` Foobar
Should Be Equal ${cookie.value} Tidii
Should Be Equal ${cookie.expires.year} ${2020}

Comment >>


return_type : CookieType = dictionary

Return Type: list[DotDict] | str

Tags:

  • Getter
  • PageContent

Returns cookies from the currently active browser context.

If return_type is dictionary or dict, then the keyword returns a list of Robot Framework dot dictionaries. Each dictionary contains all key value pairs of the cookie. See the Get Cookie keyword documentation for details about the dictionary keys and values.

If return_type is string or str, then the keyword returns the cookies as a string in format: name1=value1; name2=value2; name3=value3. The return value contains only name and value keys of the cookies. If no cookies are found, an empty list is returned.

Comment >>


id_ : str | None = ${None} Base64url-encoded credential id.
rpId : str | None = ${None} Relying party id (typically the site’s effective domain).

Return Type: ClientCredential

Tags:

  • Credential
  • Getter

Returns the credential matching the given id and/or rpId.

At least one of id_ and rpId must be given, otherwise the keyword fails. If both are given, the credential must match both of them. When more than one credential matches, the first match is returned. When no credential matches, the keyword fails.

The returned credential is a dictionary with the following keys:

Key Description
id Base64url-encoded credential id.
rpId Relying party id (typically the site’s effective domain).
userHandle Base64url-encoded user handle.
privateKey Base64url-encoded PKCS#8 (DER) private key as a Secret.
publicKey Base64url-encoded SPKI (DER) public key as a Secret.

The privateKey and publicKey are wrapped in the Secret type, so that their values are not shown in the Robot Framework log. The values themselves are available in the value attribute. Note that the node side of the library might write the whole credential, including the private key, as plain text to the playwright-log.txt file. See PlaywrightLogTypes for how to control that file.

See Install Credential for more information about how to use this keyword.

Example:

${credential} = `Get Credential` id_=${CREDENTIAL_ID}
Should Be Equal ${credential["id"]} ${CREDENTIAL_ID}
Should Be Equal ${credential["rpId"]} ${DOMAIN_NAME}
Should Be Equal ${credential["userHandle"]} userhandleCreatedByTheApp
Should Be Equal ${credential["privateKey"].value} privateKeyCreatedByTheApp
Should Be Equal ${credential["publicKey"].value} publicKeyCreatedByTheApp

download : DownloadInfo | str DownloadInfo dictionary returned from Promise To Wait For Download or download id as string.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected state of the download. Be aware that the returned value is a dictionary
message : str | None = ${None} overrides the default error message for assertion.

Return Type: DownloadInfo

Tags:

  • Assertion
  • Getter
  • PageContent

Gets the state of a download.

Returns a dictionary of type DownloadInfo with the following keys:

{
saveAs: str
suggestedFilename: str
state: str
downloadID: Optional[str]
}

Comment >>


Return Type: list[dict[str, Any]] — A list with one dictionary per application: its id, whether it is the active application, and its pages. Each page has its id, title, url, and whether it is the active page of its application.

Returns the open applications with their pages.

Every window, \<webview> and WebContentsView of an application is a page. The catalog helps to find the page id of one of them for Switch Page.

Example:

${catalog} = `Get Electron Application Catalog`
FOR ${page} IN @{catalog}[0][pages]
Log ${page}[title]: ${page}[id]
END

selection : SelectionType = ALL ALL for all open applications, ACTIVE or CURRENT for the active one.

Return Type: list[str] — A list of application ids, as Start Electron Application returned them.

Returns the ids of the open applications.

Example:

${ids} = `Get Electron Application Ids`
${active} = `Get Electron Application Ids` ACTIVE

selector : str Selector from which the element shall be retrieved. See the Finding elements section for details about the selectors.

Return Type: str

Tags:

  • Getter
  • PageContent

Returns a selector string that points to the element found by selector.

The returned string is the selector Playwright resolved for the element. It is an ordinary selector, so it can be used as the first clause of another selector, chained with >>. Because it is a selector and not a captured DOM node, it is resolved again from the page on every use.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example:

${element} = `Get Element` \#username_field
${option_value} = `Get Property` ${element} >> optionOne value # Locator is resolved from the page.
${option_value} = `Get Property` ${element} >> optionTwo value # Locator is resolved again from the page.

Comment >>


selection_strategy : SelectionStrategy SelectionStrategy to be used. Refers to Playwrights page.getBy*** functions. See https://playwright.dev/docs/locators
text : str | RegExp Text to locate the element for.
exact : bool = ${False} Whether to find an exact match: case-sensitive and whole-string. Defaults to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace. This has no effect if RegExp is used or if TestID is used as strategy.
all_elements : bool = ${False} If True, returns all matched elements as a list.

Return Type: str

Tags:

  • Getter
  • PageContent

Allows locating elements by their features.

Selection strategies can be several Playwright strategies like AltText or Label. See Playwright Locators for more information.

This keywords implements the following Playwright functions:

page.getByRole is supported by Get Element By Role keyword.

If an element shall be fetched from an iframe, a selector prefix must be set using Set Selector Prefix keyword including >>> as ending.

Comment >>


role : ElementRole Role from which shall be retrieved.
🏷all_elements : bool = ${False} If True, returns all matched elements as a list.
🏷checked : bool | None = ${None} An attribute that is usually set by aria-checked or native <input type=checkbox> controls.
🏷disabled : bool | None = ${None} An attribute that is usually set by aria-disabled or disabled.
🏷exact : bool | None = ${None} Whether name is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when name is a regular expression. Note that exact match still trims whitespace.
🏷expanded : bool | None = ${None} An attribute that is usually set by aria-expanded.
🏷include_hidden : bool | None = ${None} Option that controls whether hidden elements are matched. By default, only non-hidden elements, as defined by ARIA, are matched by role selector.
🏷level : int | None = ${None} A number attribute that is usually present for roles heading, list item, row, treeitem, with default values for <h1>-<h6> elements.
🏷name : str | RegExp | None = ${None} Option to match the accessible name. By default, matching is case-insensitive and searches for a substring, use exact to control this behavior.
🏷pressed : bool | None = ${None} An attribute that is usually set by aria-pressed.
🏷selected : bool | None = ${None} An attribute that is usually set by aria-selected.

Return Type: str

Tags:

  • Getter
  • PageContent

Returns a selector string for the element matched by role, or a list of selector strings if all_elements is set to True.

The returned value is used like the one from Get Element: as the first clause of another selector, chained with >>.

Allows locating elements by their ARIA role, ARIA attributes and accessible name.

Consider the following DOM structure.

<h3>Sign up</h3>
<label>
<input type="checkbox" /> Subscribe
</label>
<br/>
<button>Submit</button>

You can locate each element by its implicit role:

${heading} Get Element By Role heading name=Sign up
${checkbox} Get Element By Role checkbox name=Subscribe
${button} Get Element By Role button name=/submit/i

If an element shall be fetched from an iframe, a selector prefix must be set using Set Selector Prefix keyword including >>> as ending.

Comment >>


selector : str Selector which shall be counted. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : int | str = ${0} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.

Return Type: int

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the count of elements found with selector.

Optionally asserts that the count matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Example:

`Get Element Count` label > 1

Comment >>


selector : str Selector of the corresponding object. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
*assertion_expected : ElementState | str Expected states
🏷message : str | None = ${None} overrides the default error message for assertion.
🏷return_names = ${True} If set to False the keyword does return an IntFlag object (ElementState) instead of a list. ElementState may contain multiple states at the same time. Defaults to True.

Return Type: list[str] | ElementState

Tags:

  • Assertion
  • Getter
  • PageContent

Get the active states from the element found by selector.

This Keyword returns a list of states that are valid for the selected element.

Optionally asserts that the state matches the specified assertion. See Assertions for further details for the assertion arguments. By default, assertion is not done.

This keyword internally works with Python IntFlag. Flags can be processed using bitwise operators like & (bitwise AND) and | (bitwise OR). When using the assertion operators then, evaluate or validate the value contains the states as ElementState.

Example:

`Get Element States` h1 validate value & visible # Fails in case of an invisible element
`Get Element States` h1 then value & (visible | hidden) # Returns either ``['visible']`` or ``['hidden']``
`Get Element States` h1 then bool(value & visible) # Returns ``${True}`` if element is visible

The most typical use case would be to verify if an element contains a specific state or multiple states.

Example:

`Get Element States` id=checked_elem *= checked
`Get Element States` id=checked_elem not contains checked
`Get Element States` id=invisible_elem contains hidden attached
`Get Element States` id=disabled_elem contains visible disabled readonly

Elements do return the positive and negative values if applicable. As example, a checkbox does return either checked or unchecked while a text input element has none of those two states. Options of select elements have also either selected or deselected.

If an element is not attached to the DOM, so that it can not be found within 250ms, it is marked as detached as the only state.

stable state is not returned, because it would cause too high delay in that keyword.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Comment >>


selector : str Selector from which the elements shall be retrieved. See the Finding elements section for details about the selectors.

Return Type: list[str]

Tags:

  • Getter
  • PageContent

Returns a list of selector strings, one for each element matched by selector.

Each string can be used as the first clause of another selector, chained with >>, exactly like the value returned by Get Element.

Keyword does not use strict mode and returns an empty list if the selector does not match any element.

Example:

${elements} = `Get Elements` //select
${elem} = Get From List ${elements} 0
${option_value} = `Get Property` ${elem} >> option value

Comment >>


assertion_operator : AssertionOperator | None = ${None} Optional assertion operator. See Assertions for more information.
assertion_expected : Any | None = ${None} Optional expected value. See Assertions for more information.
message : str | None = ${None} Optional custom message to use on failure. See Assertions for more information.
🏷full : bool = ${False} If true, returns all page errors. If false, returns only new errors that were added since last time.
🏷last : int | timedelta | None = ${None} If set, returns only the last n entries. Can be an integer for the number of entries or a time period in Robot Framework time format.

Return Type: list[dict]

Tags:

  • Assertion
  • BrowserControl
  • Getter

Returns the page errors of the active page.

If assertions are used and fail, this keyword will fail immediately without retrying.

The returned data is a list of error messages.

An error message is a dictionary with the following structure:

{
"name": str,
"message": str,
"stack": str,
"time": str
}

Example:

[{
'name': 'ReferenceError',
'message': 'YT is not defined',
'stack': 'ReferenceError: YT is not defined\n at HTMLIFrameElement.onload (https://example.com/:20:2245)',
'time': '2023-02-05T20:08:48.912Z'
}]

Keys:

Key Description
name The name/type of the error.
message The human readable error message.
stack The stack trace of the error, if given.
time The timestamp of the error as ISO 8601 string.

Comment >>


page : SelectionType = ALL The page to get the ids from. ALL Returns all page ids as a list. ACTIVE Returns the id of the active page as a list.
context : SelectionType | str = ALL The context id or selection to get the page ids from. ALL Page ids from all contexts shall be fetched. ACTIVE Only page ids from the active context shall be fetched.
browser : SelectionType | str = ALL The browser id or selection to get the page ids from. ALL Page ids from all open browsers shall be fetched. ACTIVE Only page ids from the active browser shall be fetched.
assertion_operator : AssertionOperator | None = ${None}
*assertion_expected : Any | None
🏷message : str | None = ${None}

Return Type: list

Tags:

  • Assertion
  • BrowserControl
  • Getter

Returns a list of page ids based on the context and browser selection. See Browser, Context and Page for more information about Page and related concepts.

ALL and ANY are synonyms. ACTIVE and CURRENT are also synonyms.

Example:

Test Case
`New Page` https://www.imbus.de
`New Page` https://www.reaktor.com
${current_page}= `Get Page IDs` ACTIVE ACTIVE ACTIVE
Log Current page ID is: ${current_page}[0]
${all_pages}= `Get Page IDs` CURRENT CURRENT ALL
Log Many These are all Page IDs @{all_pages}

Example to count open pages of a specific context:

Test Case
`New Browser` firefox
${context}= `New Context`
`New Page` https://www.imbus.de
`New Page` https://www.op.fi
`New Context`
`New Page` https://www.robocon.io
${page_count}= `Get Page IDs` ALL ${context} ALL then len(value)
Should Be Equal As Integers ${page_count} 2

The ACTIVE page of the ACTIVE context of the ACTIVE Browser is the Current Page.

Comment >>

In Electron applications:

The ids are those of the windows of an application and of the \<webview> and WebContentsView elements they show. Get Electron Application Catalog returns them with their titles, and Get Window Ids returns only the windows.


assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.

Return Type: str | dict | tuple

Tags:

  • Assertion
  • Getter
  • PageContent

Gets the page’s HTML source as a string.

Optionally does a string assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

If the HTML of a single element is needed, use Get Property instead. Example:

${html1} = `Get Property` ${selector} innerHTML
${html2} = `Get Property` ${selector} outerHTML

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
property : str Requested property name.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.

Return Type: Any

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the property of the element found by selector.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the property value matches the expected value. See Assertions for further details for the assertion arguments. By default assertion is not done.

If assertion_operator is set and the property is not found, value is None and the keyword does not fail. If no assertion_operator is set and the property is not found, the keyword fails. See Get Attribute for examples.

Example:

`Get Property` h1 innerText == Login Page
${property} = `Get Property` h1 innerText

Comment >>


selector : str | None = ${None} Optional selector from which the scroll position shall be retrieved. If no selector is given the scroll position of the page itself is used (document.scrollingElement). See the Finding elements section for details about the selectors.
key : AreaFields = ALL Optionally filters the returned values. If keys is set to ALL (default) it will return the scroll position as dictionary, otherwise it will just return the single value selected by the key.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.

Return Type: ScrollPosition | float

Tags:

  • Assertion
  • Getter
  • PageContent

Gets elements or pages current scroll position as object {top: float, left: float, bottom: float, right: float}.

It describes the rectangle which is visible of the scrollable content of that element. All values are measured from position {top: 0, left: 0}.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the value matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

See Get BoundingBox or Get Scroll Size for examples.

Comment >>


selector : str | None = ${None} Optional selector from which the scroll size shall be retrieved. If no selector is given the scroll size of the page itself is used. See the Finding elements section for details about the selectors.
key : SizeFields = ALL Optionally filters the returned values. If keys is set to ALL (default) it will return the scroll size as dictionary, otherwise it will just return the single value selected by the key.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.

Return Type: Dimensions | float | int

Tags:

  • Assertion
  • Getter
  • PageContent

Gets elements or pages scrollable size as object {width: float, height: float}.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the state matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

See Get BoundingBox for more similar examples.

Example use:

${height}= `Get Scroll Size` height # filtered page by height
Log Height: ${height} # Height: 58425
${scroll_size}= `Get Scroll Size` id=keyword-shortcuts-container # unfiltered element
Log ${scroll_size} # {'width': 253, 'height': 3036}

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.

Return Type: list[SelectOptions]

Tags:

  • Assertion
  • Getter
  • PageContent

Returns attributes of options of a select element as a list of dictionaries.

Each returned dictionary has the keys “index”, “value”, “label” and “selected”.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that these match the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Example:

`Get Select Options` //select[2] validate [v["label"] for v in value] == ["Email", "Mobile"]
`Get Select Options` select#names validate any(v["label"] == "Mikko" for v in value)

Comment >>


selector : str Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
option_attribute : SelectAttribute = label Which attribute shall be returned/verified. Defaults to label.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
*assertion_expected Expected value for the state
🏷message : str | None = ${None} overrides the default error message for assertion.

Return Type: list[str | int]

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the specified attribute of selected options of the select element.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that these match the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

  • == , != and contains / *= can work with multiple values
  • validate and evaluate only accept one single expected value

Other operators are not allowed.

Example:

`Select Options By` label //select[2] Email Mobile
${selected_list} = `Get Selected Options` //select[2] # getter
`Get Selected Options` //select[2] label == Mobile Mail #assertion content
`Select Options By` label select#names 2 4
`Get Selected Options` select#names index == 2 4 #assertion index
`Get Selected Options` select#names label *= Mikko #assertion contain
`Get Selected Options` select#names label validate len(value) == 3 #assertion length

Comment >>


selector : str Selector from which the style shall be retrieved. See the Finding elements section for details about the selectors.
key : str | None = ALL Key of the requested CSS property. Retrieves “ALL” styles as dictionary by default. All css settings can be used as keys even if they are not all returned in the dictionary.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.
pseudo_element : str | None = ${None} Pseudo element to match. Defaults to None.

Return Type: dict[str, str] | str | tuple | dict

Tags:

  • Assertion
  • Getter
  • PageContent

Gets the computed style properties of the element selected by selector.

A pseudo element is a CSS functionality to add styles, for example ::before or ::after.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Optionally asserts that the style matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

When key is ALL, a dictionary is returned and only the sequence assertion operators ==, !=, contains / *=, validate and evaluate / then are allowed. Assertion formatters are not applied in that case.

Comment >>


table : str selector must select the \<table> element that contains both selected elements
column : str selector can select any \<th> or \<td> element or one of their descendants.
row : str selector can select any \<tr> element or one of their descendants like \<td> elements.

Return Type: str

Tags:

  • Getter
  • PageContent

Returns a selector string for the cell at the same column and row index as the selected elements.

The returned value is used like the one from Get Element.

column and row can also consume index numbers instead of selectors. Indexes are starting from 0 and -1 is specific for the last element.

Selectors for column and row are directly appended to the table selector like this: f"{table} >> {column}" and f"{table} >> {row}".

GitHub Slack Real Name
mkorpela @mkorpela Mikko Korpela
aaltat @aaltat Tatu Aalto
xylix @Kerkko Pelttari Kerkko Pelttari
Snooz82 @René René Rohner

Example:

${table}= Set Variable [id="Get Table Cell Element"] >> div.kw-docs table >> nth=1
${e}= `Get Table Cell Element` ${table} "Real Name" "aaltat" # Returns element with text ``Tatu Aalto``
Get Text ${e} == Tatu Aalto
${e}= `Get Table Cell Element` ${table} "Slack" "Mikko Korpela" # Returns element with text ``@mkorpela``
Get Text ${e} == @mkorpela
${e}= `Get Table Cell Element` ${table} "mkorpela" "Kerkko Pelttari" # column does not need to be in row 0
Get Text ${e} == @mkorpela
${e}= `Get Table Cell Element` ${table} 2 -1 # Index is also directly possible
Get Text ${e} == René Rohner

Comment >>


selector : str can select any \<th> or \<td> element or one of their descendants. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : int | str = ${0} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.

Return Type: int

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the index (0 based) of a table cell within its row.

Example:

${table}= Set Variable id=`Get Table Cell Element` >> div.kw-docs table #Table of keyword `Get Table Cell Element`
${idx}= `Get Table Cell Index` ${table} >> "Real Name"
Should Be Equal ${idx} ${2}
`Get Table Cell Index` ${table} >> "@aaltat" == 1

Optionally asserts that the index matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Comment >>


selector : str can select any \<tr>, \<th> or \<td> element or one of their descendants. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : int | str = ${0} Expected value for the assertion
message : str | None = ${None} overrides the default error message for assertion.

Return Type: int

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the index (0 based) of a table row.

Example:

${table}= Set Variable id=`Get Table Cell Element` >> div.kw-docs table #Table of keyword `Get Table Cell Element`
${idx}= `Get Table Row Index` ${table} >> "@René"
Should Be Equal ${idx} ${4}
`Get Table Row Index` ${table} >> "@aaltat" == 2

Optionally asserts that the index matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Comment >>


selector : str Selector from which the text is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.
🏷text_type : TextType | None = ${None} How text is returned. Possible values are allInnerTexts, allTextContents, innerText, inputValue, and innerHTML. Defaults to None, which returns the value of input and textarea elements and the inner text of all other elements.

Return Type: str | list[str] | dict | tuple

Tags:

  • Assertion
  • Getter
  • PageContent

Returns text attribute of the element found by selector.

Keyword can also return the value property text of input or textarea elements. See the Finding elements section for details about the selectors.

Keyword uses strict mode, see Finding elements for more details about strict mode. The text_type argument determines how text is returned. The allInnerTexts and allTextContents will return a list of strings, while other types return a single string.

Optionally asserts that the text matches the specified assertion. See Assertions for further details for the assertion arguments. By default, assertion is not done.

Example:

${text} = `Get Text` id=important # Returns element text without assertion.
${text} = `Get Text` id=important == Important text # Returns element text with assertion.
${text} = `Get Text` //input == root # Returns input element text with assertion.
${text} = `Get Text` id=important text_type=innerHTML # Returns element inner HTML.
${text} = `Get Text` id=important text_type=allInnerTexts # Returns element inner text as list of strings.

Comment >>


assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.

Return Type: str | dict | tuple

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the title of the current page.

Optionally asserts that title matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Comment >>


assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the state
message : str | None = ${None} overrides the default error message for assertion.

Return Type: str | dict | tuple

Tags:

  • Assertion
  • Getter
  • PageContent

Returns the current URL.

Optionally asserts that it matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

Comment >>


key : SizeFields = ALL Optionally filters the returned values. If keys is set to ALL (default) it will return the viewport size as dictionary, otherwise it will just return the single value selected by the key. Note: If a single value is retrieved, an assertion does not need a validate combined with a cast of value.
assertion_operator : AssertionOperator | None = ${None} See Assertions for further details. Defaults to None.
assertion_expected : Any | None = ${None} Expected value for the assertion
message : str | tuple | dict | None = ${None} overrides the default error message for assertion.

Return Type: ViewportDimensions | None

Tags:

  • Assertion
  • BrowserControl
  • Getter

Returns the current viewport dimensions.

Optionally asserts that the state matches the specified assertion. See Assertions for further details for the assertion arguments. By default assertion is not done.

If the page does not have a viewport size, for example because the context was created without one, None is returned and no assertion is done.

Example:

`Get Viewport Size` ALL == {'width':1280, 'height':720}
`Get Viewport Size` width >= 1200

Comment >>

In Electron applications:

Returns None for the window of an application, which has no emulated viewport. Get Window Size returns the size that the window’s page has.


selection : SelectionType = ALL ALL for all windows, in the order in which they opened, ACTIVE or CURRENT for the window that shows the active page.

Return Type: list[str] — A list of window ids such as window=1, which the window keywords take, for example Maximize Window and Switch Window.

Returns the ids of the active application’s windows.

The windows are the application’s BrowserWindow objects. A \<webview> or WebContentsView is a page, but no window, see Windows and pages. The ids are valid while the application runs.

Example:

${windows} = `Get Window Ids`
`Maximize Window` ${windows}[1]
${active} = `Get Window Ids` ACTIVE

key : SizeFields = ALL ALL returns a dictionary with width and height, width or height only that value.
assertion_operator : AssertionOperator | None = ${None} See Assertions.
assertion_expected : Any | None = ${None} The expected value of the assertion.
message : str | None = ${None} Overrides the default error message of the assertion.
window : str | None = ${None} The window, see Windows and pages. Defaults to the window that shows the active page. After the assertion arguments, it is given by name.

Return Type: Any

Returns the content size of a window.

The content size is the area that the window’s page shows, see Set Window Size. Browser’s Get Viewport Size returns None for an application’s window, which has no emulated viewport.

Example:

${size} = `Get Window Size`
`Get Window Size` width == 1280
`Get Window Size` ALL == {'width': 1024, 'height': 700} window=title=Settings

assertion_operator : AssertionOperator | None = ${None} See Assertions.
assertion_expected : Any | None = ${None} The expected value of the assertion.
message : str | None = ${None} Overrides the default error message of the assertion.
window : str | None = ${None} The window, see Windows and pages. Defaults to the window that shows the active page. After the assertion arguments, it is given by name.

Return Type: Any

Returns the state of a window: normal, maximized or minimized.

A fullscreen window, which fills the screen, counts as maximized.

Example:

`Get Window State` == maximized
${state} = `Get Window State` window=title=Settings

Return Type: list[str]

Returns the titles that the active application’s windows show.

The titles are in the order of Get Window Ids. A window shows the title of its page, unless the application gives it one of its own. The window keywords take a window by its title, see Windows and pages.

Example:

${titles} = `Get Window Titles`
Should Contain ${titles} Settings
`Switch Window` title=Settings

Tags:

  • BrowserControl
  • Setter

Navigates to the previous page in history.

If the wait times out, the page’s load report is logged: whether its navigation committed, how far the document got and which requests were still open.

Comment >>


Tags:

  • BrowserControl
  • Setter

Navigates to the next page in history.

If the wait times out, the page’s load report is logged: whether its navigation committed, how far the document got and which requests were still open.

Comment >>


url : str URL to be navigated to.
timeout : timedelta | None = ${None} Time to wait for the page to load. If not defined, the library default timeout is used.
wait_until : PageLoadStates = load When to consider the operation succeeded, defaults to load. The event can be either: domcontentloaded - consider the operation to be finished when the DOMContentLoaded event is fired. load - consider the operation to be finished when the load event is fired. networkidle - consider the operation to be finished when there are no network connections for at least 500 ms. commit - consider the operation to be finished when the network response is received and the document started loading.

Tags:

  • BrowserControl
  • Setter

Navigates to the given url.

Returns the HTTP status code of the navigation request as an integer, or 0 if no response was received.

If the wait times out, the page’s load report is logged: whether its navigation committed, how far the document got and which requests were still open.

Comment >>


*permissions : Permission Permissions to grant, given as separate arguments. See Permission for the available values, for example geolocation, notifications, camera or microphone.
🏷origin : str | None = ${None} The origin to grant the permissions to, e.g. “https://example.com”. If not given, the permissions are granted for all origins.

Tags:

  • BrowserControl
  • Setter

Grants permissions to the current context.

Example:

`New Context`
`Grant Permissions` geolocation

Comment >>


action : DialogAction How to handle the alert. Can be accept or dismiss.
prompt_input : str = ${EMPTY} The value to enter into the prompt. Only valid if the action argument equals accept. Defaults to an empty string.

Tags:

  • PageContent

Handle next dialog on page with action.

The dialog can be an alert, beforeunload, confirm or prompt dialog. This keyword must be called before the action, for example a click, which triggers the dialog.

The handler is registered on the current page and stays in effect for all following dialogs on that page. Calling this keyword again on the same page replaces the handler, so the latest call decides how dialogs are handled.

If a handler is not set, dialogs are dismissed by default.

The handler runs when the dialog appears, not while this keyword executes, so a failure to accept or dismiss the dialog can not be raised as a keyword failure. Such a failure is reported in the playwright-log.txt file only, which is linked into the Robot Framework log when a keyword fails.

Example:

`Handle Future Dialogs` action=accept
`Click` \#alerts

Comment >>

In Electron applications:

Electron does not implement prompt(): a page’s call fails with prompt() is not supported., so prompt_input never applies. Native dialogs of the main process are not dialogs of the page; replace them with Evaluate In Main Process.


selector : str Selectors which shall be highlighted. See the Finding elements section for details about the selectors.
duration : timedelta = 0:00:05 Sets for how long the selector shall be highlighted. Defaults to 5s => 5 seconds. If set to 0 seconds, the highlighting is not deleted.
width : str = 2px Sets the width of the highlight border. Defaults to 2px.
style : str = dotted Sets the style of the border. Defaults to dotted.
color : str = blue Sets the color of the border. Valid colors i.e. are: red, blue, yellow, pink, black
🏷mode : HighlightMode = border Sets the mode of the highlight. Valid modes are: border (classic mode), playwright (Playwright’s native one) and both. Defaults to border. If playwright is used, width, style and color are ignored and only one highlighting can happen at the same time.

Tags:

  • PageContent
  • Setter

Adds a highlight to elements matched by the selector. Provides a style adjustment.

Returns the number of highlighted elements. Keyword does not fail, if the selector matched zero elements in the page. Keyword does not scroll elements to viewport and highlighted element might be outside the viewport. Use Scroll To Element keyword to scroll element in viewport.

Keyword does not fail if selector resolves to multiple elements.

Highlights which are created with duration=0 stay in the page until they are removed. Calling this keyword with an empty selector, for example Highlight Elements ${EMPTY}, removes all such highlights that were made with Playwright’s native highlighting, in other words with mode=playwright or mode=both. Highlights drawn in border mode can not be removed that way.

Example:

`Highlight Elements` input#login_button duration=200ms
${count} = `Highlight Elements` input#login_button duration=200ms width=4px style=solid color=\#FF00FF
Should Be Equal ${count} ${5}

Comment >>


selector : str Selector element to hover. See the Finding elements section for details about the selectors.
position_x : float | None = ${None} A point to hover relative to the top-left corner of element bounding box. If not specified, hovers over some visible point of the element. Only positive values within the bounding-box are allowed. Both values must be given, otherwise the position is ignored.
position_y : float | None = ${None} A point to hover relative to the top-left corner of element bounding box. If not specified, hovers over some visible point of the element. Only positive values within the bounding-box are allowed. Both values must be given, otherwise the position is ignored.
force : bool = ${False} Set to True to skip Playwright’s Actionability checks. Defaults to False.
*modifiers : KeyboardModifier Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used. Valid modifier keys are Alt, Control, ControlOrMeta, Meta and Shift.

Tags:

  • PageContent
  • Setter

Moves the virtual mouse and scrolls to the element found by selector.

This method hovers over an element matching selector by performing the following steps:

  • Find an element matching selector. If there is none, wait until a matching element is attached to the DOM.
  • Wait for actionability checks on the matched element, unless the force option is set. If the element is detached during the checks, the whole action is retried.
  • Scroll the element into view if needed.
  • Use Mouse Move to hover over the center of the element, or the specified position.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example:

`Hover` h1
`Hover` h1 10 20 Alt

Comment >>


url : str The request url, e.g. /api/foo.
method : RequestMethod = GET The HTTP method for the request. Defaults to GET.
body : str | None = ${None} The request body. It is ignored for GET requests, because GET requests cannot have a body. If the body can be parsed as JSON, the Content-Type header for the request is automatically set to application/json, unless headers already contains that header. Defaults to None.
headers : dict | None = ${None} A dictionary of additional request headers. Defaults to None.

Return Type: Any

Tags:

  • HTTP

Performs an HTTP request in the current browser context

The request is sent with the browser’s fetch from the currently active page, so a relative url is resolved against the URL of that page.

The response is a Robot Framework dictionary with the following attributes:

  • status <int> The status code of the response.
  • statusText <str> Status text corresponding to status, e.g. OK or INTERNAL SERVER ERROR. This may not be available for all browsers.
  • body <dict> | <str> The response body. If the body can be parsed as a JSON object, it will be returned as Python dictionary, otherwise it is returned as a string.
  • headers <dict> A dictionary containing all response headers.
  • ok <bool> Whether the request was successful, i.e. the status is in the range 200-299.
  • url <str> The final URL of the response, after possible redirects.
  • redirected <bool> Whether the response is the result of a redirect.
  • type <str> The type of the response, e.g. basic or cors.

Here’s an example of using Robot Framework dictionary variables and extended variable syntax to do assertions on the response object:

&{res}= `HTTP` /api/endpoint
Should Be Equal ${res.status} 200
Should Be Equal ${res.body.some_field} some value

Comment >>


Tags:

  • Credential
  • Setter

Installs the virtual WebAuthn authenticator into the context.

Overrides navigator.credentials.create() and navigator.credentials.get() in all current and future pages of the context. Call this before the page first touches navigator.credentials.

Until the authenticator is installed, no interception is in place and the page sees the platform’s native (or absent) WebAuthn behavior. Create Credential installs the authenticator as well, so this keyword is mainly needed when the credentials are created by the application itself. There must be an open context, otherwise the keyword fails.

Example:

`New Context`
`Install Credential`
`New Page` ${SUT_URL}
# Do something on the page that causes the page to call ``navigator.credentials.create()``
${credential_id} = Get Credential Id # This is a user keyword that returns the credential id from somewhere. Talk to your application team to find out how to get the credential id.
${credential} = `Get Credential` id_=${credential_id} # This will return the credential that was created by the application and installed into the context.
`New Context`
`Create Credential`
... rpId=${DOMAIN_NAME}
... id_=${credential["id"]}
... privateKey=${credential["privateKey"]}
... publicKey=${credential["publicKey"]}
... userHandle=${credential["userHandle"]}
`New Page` ${SUT_URL}
# User should be able to interact with the page using the installed credential.

action : KeyboardInputAction insertText: Dispatches only input event, does not emit the keydown, keyup or keypress events. type: Sends a keydown, keypress/input, and keyup event for each character in the text.
input : str The input string to be typed. No special keys possible.
delay : int | timedelta = 0:00:00 Time to wait between key presses in Robot Framework’s time format. Defaults to 0 ms.

Tags:

  • PageContent
  • Setter

Input text into page with virtual keyboard.

Attention: Argument type int for ‘delay’ in milliseconds has been changed to timedelta in Browser 14.0.0. Use Robot Framework time format with units instead.

Note: To press a special key, like Control or ArrowDown, use Keyboard Key. Modifier keys DO NOT affect these actions. For testing modifier effects use single key presses with Keyboard Key press

Example:

`Keyboard Input` insertText 0123456789

Comment >>


action : KeyAction Determines whether the key should be released (up), held down (down) or pressed once (press). down and up are useful for combinations, i.e. with Shift.
key : str The key to be pressed. Examples of valid keys are: F1 - F12, Digit0 - Digit9, KeyA - KeyZ, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrowRight, ArrowUp , etc.
🏷delay : timedelta = 0:00:00 Time the key is held down between keydown and keyup, in Robot Framework’s time format. Only valid with action press, other actions raise an error. Defaults to 0 s. Example: 50 ms

Tags:

  • PageContent
  • Setter

Press a keyboard key on the virtual keyboard or set a key up or down.

Useful keys for down and up for example are: Shift, Control, Alt, Meta, ShiftLeft

Example execution:

`Keyboard Key` press S
`Keyboard Key` press S delay=500 ms
`Keyboard Key` down Shift
`Keyboard Key` press ArrowLeft
`Keyboard Key` press Delete
`Keyboard Key` up Shift

Note: Capital letters don’t need to be written by the help of Shift. You can type them in directly.

Comment >>

In Electron applications:

The keys reach the page, but not the accelerators of the application’s menu. Click a menu item in the main process instead, see Evaluate In Main Process.


frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Tags:

  • PageContent
  • Setter

Remove all saved data from the local storage.

Example:

`LocalStorage Set Item` Foo bar
`LocalStorage Clear`
${item} = `LocalStorage Get Item` Foo
Should Be Equal ${item} ${None}

Comment >>


key : str Named key of the item in the storage.
assertion_operator : AssertionOperator | None = ${None} Assertion operator to use. See Assertions for more information.
assertion_expected : Any | None = ${None} Expected value to compare with.
message : str | None = ${None} Custom error message to use.
frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Return Type: Any

Tags:

  • Assertion
  • Getter
  • PageContent

Get saved data from the local storage.

See Assertions for further details about the assertion arguments. They default to None.

If the key does not exist in the storage, ${None} is returned.

Example:

`LocalStorage Get Item` Key == Value My error
${value} = `LocalStorage Get Item` Key

Comment >>


key : str The name of the item which shall be deleted.
frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Tags:

  • PageContent
  • Setter

Remove saved data with key from the local storage.

Example:

`LocalStorage Set Item` Foo bar
`LocalStorage Remove Item` Foo
${item} = `LocalStorage Get Item` Foo
Should Be Equal ${item} ${None}

Comment >>


key : str The name of the key under which it should be saved.
value : str The value which shall be saved as a string.
frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Tags:

  • PageContent
  • Setter

Save data to the local storage.

Example:

`LocalStorage Set Item` Key Value

Comment >>


window : str | None = ${None} The window, see Windows and pages. Defaults to the window that shows the active page.

Return Type: None

Maximises a window and waits until it is maximised.

A fullscreen window leaves fullscreen first. Maximising needs a window manager. On a display without one, for example plain Xvfb, the keyword fails after the library timeout.

Example:

`Maximize Window`
`Maximize Window` title=Settings

input_folder : Path Path to the base folder where the raw coverage reports are located.
output_folder : Path Path to the folder where the combined report is stored.
config_file : Path | None = ${None} Optional path to options file
name : str | None = ${None} Optional name for the combined report.
reports : list[str] | None = ${None} Optional list of reporters to create. Default is v8.

Return Type: Path

Tags:

  • Coverage
  • Setter

Combines multiple raw coverage reports into a single report.

Returns the path to the output_folder.

The input_folder argument is the base folder where the coverage reports are located. The keyword will look into each subfolder and if the subfolder contains a “raw” folder, it will use the data from the “raw” folder for the combined report.

The output_folder argument is the folder where the combined report is saved. If the folder does not exist, it is created. If the folder exists, its content is deleted before the report is created.

The output_folder and input_folder must be full paths to the folders.

The config_file argument is optional and can be used to provide a path to a monocart-coverage-reports options file. If the file is defined but does not exist, the keyword fails. For more details see: https://www.npmjs.com/package/monocart-coverage-reports#config-file

The name argument is optional and can be used to provide a name for the combined report. If it is not defined, the report is named “Browser library Merged Coverage Report”.

The reports argument is optional and can be used to provide a list of reporters to create. Default is v8.

The keyword combines only the raw reports. To get raw reports, the Start Coverage keyword must be called with the raw=True argument. If no raw reports are found from the input_folder, the keyword fails. The keyword should be used when there is a need to combine multiple reports into a single report. For example, when tests are run in multiple pages. The example below demonstrates how to use the keyword.

Example:

`New Page`
`Start Coverage`
`Go To` ${LOGIN_URL}
Test Feature X In The Page
`Stop Coverage`
`New Page`
`Start Coverage`
`Go To` ${LOGIN_URL}
Test Feature Y In The Page
`Stop Coverage`
`Merge Coverage Reports` ${OUTPUT_DIR}/browser/coverage ${OUTPUT_DIR}/browser/combined-coverage

window : str | None = ${None} The window, see Windows and pages. Defaults to the window that shows the active page.

Return Type: None

Minimises a window and waits until it is minimised.

A minimised window draws nothing, so Browser keywords on its page wait until their timeout. Restore Window brings it back. A fullscreen window leaves fullscreen first. Minimising needs a window manager, and some desktops cannot minimise windows, for example niri. There, the keyword fails after the library timeout.

Example:

`Minimize Window`
`Restore Window`

action : MouseButtonAction Defines if it is a mouseclick (click), holding down a button (down) or releasing it (up).
x : float | None = ${None} Coordinates to move to before the action is executed. Both must be given, otherwise the action happens at the current mouse position.
y : float | None = ${None} Coordinates to move to before the action is executed. Both must be given, otherwise the action happens at the current mouse position.
button : MouseButton = left One of left, middle or right. Defaults to left.
clickCount : int = ${1} Determines how often the button shall be clicked if action is equal to click. Defaults to 1.
delay : int | timedelta = 0:00:00 Delay in Robot Framework time format between the mousedown and mouseup event. Can only be set if the action is click. Defaults to 0 s.

Tags:

  • PageContent
  • Setter

Clicks, presses or releases a mouse button.

Attention: Argument type int for ‘delay’ in milliseconds has been changed to timedelta in Browser 14.0.0. Use Robot Framework time format instead. For refactoring just add ‘ms’ after the delay number.

Delay Example:

`Mouse Button` click delay=100 ms
`Mouse Button` click delay=${dyn_delay} ms

Moving the mouse between holding down and releasing it is possible with Mouse Move.

Example:

`Hover` "Obstacle" # Move mouse over the element
`Mouse Button` down # Press mouse button down
`Mouse Move Relative To` "Obstacle" 500 # Drag mouse
`Mouse Button` up # Release mouse button

Comment >>


x : float Absolute coordinate starting at the left border of the page.
y : float Absolute coordinate down starting at the top border of the page.
steps : int = ${1} Number of intermediate steps for the mouse event. Often it is necessary to send more than one intermediate event to get the desired result. Defaults to 1.

Tags:

  • PageContent
  • Setter

Moves the virtual mouse to the given coordinates, instead of to an element found by a selector.

The virtual mouse is left on the specified coordinates.

Example:

`Mouse Move` 400 400

Comment >>


selector : str Identifies the element whose center is the start-point.
x : float = ${0.0} Coordinates relative to the center of the element’s bounding box.
y : float = ${0.0} Coordinates relative to the center of the element’s bounding box.
steps : int = ${1} Number of intermediate steps for the mouse event. Often it is necessary to send more than one intermediate event to get the desired result. Defaults to 1.

Tags:

  • PageContent
  • Setter

Moves the mouse cursor relative to the selected element.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example:

`Mouse Move Relative To` id=indicator -100

Comment >>


deltaX : int Pixels that are scrolled horizontally.
deltaY : int Pixels that are scrolled vertically.

Tags:

  • PageContent
  • Setter

Simulates the user rotation of a mouse wheel.

Example:

# Before doing a mouse wheel interaction. A mouse needs to be positioned on the browser window.
`Hover` body
`Mouse Wheel` 0 250

Comment >>


time : datetime The time to pause the clock at.

Tags:

  • Clock
  • Setter

Advances the clock by jumping forward in time and pauses it.

Fires due timers at most once. This is equivalent to a user closing the laptop lid for a while and reopening it at the specified time and then pausing. Pause can not move the clock backwards.

Example:

`Set Time` 2024-10-31 17:34:00 # Set the clock to a specific time
Do Something # Implement this in your keyword
`Pause At` 2024-10-31 18:34:00 # Pause the clock at a specific time
Check Something # Also this is implemented in your keyword
`Resume Clock` # Resume the clock
Do Something Else # Do something after clock runs normally

selector : str Selector of the text field. See the Finding elements section for details about the selectors.
*keys : str Keys to be pressed one after the other. Combining modifiers with a single key press by chaining them with +, like Control+Shift+T, is supported.
🏷press_duration : timedelta = 0:00:00 Delay between keydown and keyup of each key. Can be given as seconds (float) or as Robot Framework time string. Defaults to 0 ms. Example: 50 ms
🏷key_delay : timedelta = 0:00:00 Delay between key presses. Can be given as seconds (float) or as Robot Framework time string. Defaults to 0 ms. Example: 50 ms

Tags:

  • PageContent
  • Setter

Types the given key combination into element found by selector.

Supports values like a or b which will be automatically typed.

Also supports identifiers for keys like ArrowLeft or Backspace.

Keyword uses strict mode, see Finding elements for more details about strict mode.

See Playwright’s documentation for a more comprehensive list of supported input keys. Playwright docs for press.

Example:

# Keyword Selector *Keys
`Press Keys` //*[@id="username_field"] h e l o ArrowLeft l

Comment >>

In Electron applications:

The keys reach the page, but not the accelerators of the application’s menu. Click a menu item in the main process instead:

`Evaluate In Main Process` ({ Menu }) => Menu.getApplicationMenu().getMenuItemById('open-file').click()

kw : str Keyword that will run asynchronously in the background.
*args Keyword arguments as normally used.

Return Type: Future

Tags:

  • Wait

Wrap a Browser library keyword and make it a promise.

The promised keyword is started in the background. Test execution continues without waiting for kw to finish.

Returns a reference to the promised keyword. Use Wait For or Wait For All Promises to wait for its result. Promises that are never waited for are waited for automatically at the end of the test, and a warning is logged.

Only Browser library keywords can be promised, any other keyword name fails the keyword.

Example:

${promise}= `Promise To` Wait For Response matcher= timeout=3
`Click` \#delayed_request
${body}= `Wait For` ${promise}

Comment >>


path : PathLike Path to file to be uploaded.

Return Type: Future

Tags:

  • PageContent
  • Setter

Returns a promise that resolves when the file from path has been uploaded.

The file from path is uploaded into the next file chooser dialog on the page.

The keyword fails immediately if path does not point to an existing file. The promise fails if no file chooser dialog is opened within the timeout.

Example use:

${promise}= `Promise To Upload File` ${CURDIR}/test_upload_file.txt
`Click` id=open_file_chooser_button
${upload_result}= `Wait For` ${promise}

Alternatively, you can use the Upload File By Selector keyword.

Comment >>


saveAs : str = ${EMPTY} Defines path where the file is saved persistently. File will also temporarily be saved in playwright context’s default download location. If empty, generated unique path (GUID) is used and file is deleted when the context is closed.
wait_for_finished : bool = ${True} If true, promise will wait for download to finish. If false, promise will resolve immediately after download has started.
download_timeout : timedelta | None = ${None} Maximum total time for the download to start and finish, counted from the moment the promise is created. If the download does not start within this time, the keyword fails. If it starts but does not finish, it is cancelled and the keyword fails. If wait_for_finished is False, only the start is limited. If not set, the download must start within the browser timeout, see Set Browser Timeout, and there is no limit for it to finish.

Return Type: Future

Tags:

  • BrowserControl
  • Wait

Returns a promise that waits for the next download event on the page.

To enable downloads the context’s acceptDownloads needs to be true.

With the default file path downloaded files are deleted when the context the download happened in is closed.

If browser is connected remotely with Connect To Browser then saveAs must be set to store it locally where the browser runs!

Keyword returns dictionary of type DownloadInfo which contains downloaded file path and suggested filename as well as state and downloadID. Example:

{
"saveAs": "/tmp/robotframework-browser/downloads/2f1b3b7c-1b1b-4b1b-9b1b-1b1b1b1b1b1b",
"suggestedFilename": "downloaded_file.txt",
"state": "finished",
"downloadID": None
}

If wait_for_finished is False, saveAs is an empty string, state is in_progress and downloadID contains an id which can be used with Get Download State to check the download later.

The keyword New Browser has a downloadsPath setting which can be used to set the default download directory. If saveAs is set to a relative path, the file will be saved relative to the browser’s downloadsPath setting or if that is not set, relative to the Playwright’s working directory. If saveAs is set to an absolute path, the file will be saved to that absolute path independent of downloadsPath.

Set download_timeout when the download can take longer than the browser timeout, for example when the server generates the file before sending it.

If the URL for the file to download shall be used, Download keyword may be a simpler alternative way to download the file.

The waited promise returns a dictionary which contains saveAs and suggestedFilename as keys. The saveAs contains the location where the file is downloaded and suggestedFilename contains the suggested name for the download. The suggestedFilename is typically computed by the browser from the Content-Disposition response header or the download attribute. See the spec on whatwg. Different browsers can use different logic for computing it.

Example usage:

`New Context` acceptDownloads=True
`New Page` ${LOGIN_URL}
${dl_promise} `Promise To Wait For Download` /path/to/download/file.name download_timeout=30s
`Click` id=file_download
${file_obj}= `Wait For` ${dl_promise}
File Should Exist ${file_obj}[saveAs]
Should Be True ${file_obj.suggestedFilename}

Comment >>


name : str
file : str | None = \${SUITE_SOURCE}
idle_timeout : timedelta | None = 0:05:00

Return Type: str

Tags:

  • Recorder

Record browser interactions as one User Keyword named name.

Shows the Robot Framework recorder toolbar on the pages of the current browser context and blocks until the recording ends. Every Action becomes a Keyword Call to a Browser keyword, is listed in the toolbar and is written to file immediately.

Toolbar buttons (each has a tooltip):

  • ✕ in the header: ends the session.
  • Minimize in the header (a dash): minimizes the toolbar.
  • Discard: drops the Keyword Calls recorded so far and starts the keyword again, empty.
  • Undo: removes the Keyword Calls of the last Action.
  • Pause (two bars): stops recording until Resume; Actions in between are not recorded.
  • Pick in the header: picks an element on the page, as Record Selector does, and adds its selector to the keyword as a comment row \# Picked Selector \<selector>. Playwright’s own Pick locator button opens the same picker. While picking, nothing is recorded; Cancel returns to recording without a row.

The toolbar is in the recording state from the start. Click a value or a selector in the toolbar to turn the whole of it, or a marked part, into a Keyword Argument, named like email or ${email}. The same dialog asks whether the marked value becomes the argument’s default. The toolbar also offers to use the new argument for the same value elsewhere in the keyword (replacing repeated values).

The keyword is always created new: an existing keyword is never extended.

The recording ends with Save or ✕ in the toolbar, with Playwright’s Record button, when idle_timeout passes without any Action or toolbar command, when all pages are closed, or on an error. The keyword being recorded is saved unless it has no Keyword Calls.

Arguments Description
name Name of the User Keyword to create. It must not exist in file and must not shadow any keyword the running suite can call.
file Target .robot or .resource file. Defaults to ${SUITE_SOURCE}, the file of the running suite; in a suite initialisation file that is its __init__.robot, and a keyword recorded there can only be used in that file. A relative path is resolved against the current working directory, not against the suite; use ${CURDIR} for a file next to the suite. The folder must exist and an existing file must be writable; both are checked before recording starts. With ${None} nothing is written; the keyword is logged to the console and to the log at INFO level instead.
idle_timeout Ends the recording after this long without an Action or toolbar command. Must be greater than zero. Default: 5 minutes, so a forgotten recording does not block the run for good. ${None} waits without limit.

Returns the text of the recorded keyword, including the *** Keywords *** header. If a recorded keyword cannot be written - the file became read-only, the disk is full - the keyword fails, and the recorded text is logged as a warning so nothing is lost.

What is generated: every keyword gets [Tags] recorded. A popup or new tab becomes Switch Page NEW. An Action on another open page gets a Switch Page to it first, using the id the Switch Page that left that page returned (${page}= Switch Page NEW); a page closed by hand becomes Close Page, or Close Page ${page} when it is not the active one. A page the keyword has no id of, for example one open before the recording, cannot be switched to, and the toolbar says so. A dialog gets Handle Future Dialogs action=accept before the Action (Playwright does not report whether the dialog was accepted); a download is wrapped in Promise To Wait For Download and Wait For. A file chosen in a file chooser wraps the click that opened it in Promise To Upload File and Wait For; the page never reveals the file’s folder, so the path reads \<define_path_to_file>/\<file name> and must be completed (or made an argument). Playwright’s Assert snapshot becomes Get Aria Snapshot with an exact YAML comparison, and Assert visibility becomes Get Element States ... *= visible. Playwright folds a navigation that happens within 5 seconds after a click, fill or key press into that Action, so it is not recorded as a Go To of its own. Hovers are not recorded, because Playwright does not report them. Other Actions without a Browser keyword are only reported in the toolbar.

Needs a visible browser: fails if the active browser was opened headless, since nobody could use the toolbar there. A browser attached with Connect To Browser is assumed to be visible.

Limitations: only the current browser context is recorded; other contexts are ignored. Playwright’s own recorder toolbar is shown at the top centre of the page during the recording and cannot be hidden, so it covers the page there. The toolbar does not appear on a page whose Content-Security-Policy allows only Trusted Types policies it names, nor in a document without a body, such as an SVG file. A modal \<dialog> of the page covers the toolbar until it is closed, and a click there is recorded on the dialog.

Review a recorded keyword before you commit it. Its values come from the page under test, including anything typed into password fields. During the session the toolbar state, including the recorded values and typed text, is readable by scripts of every page in the context, and those scripts can send toolbar commands. Keystrokes typed into the toolbar do not reach the page, except to a window capture listener the page registered before the toolbar was injected.

Requires a Playwright version that offers the programmatic recorder. The context stays prepared for recording after the session ends.

Example:

${text} = Record Keyword Login As Admin
Record Keyword Search Product ${CURDIR}/shop.resource idle_timeout=15 min
Record Keyword Try Something file=${None}

See Record Keywords to record several keywords in one session.


file : str | None = \${SUITE_SOURCE}
idle_timeout : timedelta | None = 0:05:00

Return Type: str

Tags:

  • Recorder

Record several User Keywords in one session.

Use Record keyword in the toolbar to name and start a keyword, record it, and Save it; then start the next one. Actions while no keyword is being recorded are not captured, so you can navigate freely between keywords. A name must not exist in file, must not have been recorded earlier in the session, and must not shadow any keyword the running suite can call - such names are rejected in the toolbar.

Shows the Robot Framework recorder toolbar on the pages of the current browser context and blocks until the recording ends. Every Action becomes a Keyword Call to a Browser keyword, is listed in the toolbar and is written to file immediately.

Toolbar buttons (each has a tooltip):

  • ✕ in the header: ends the session.
  • Minimize in the header (a dash): minimizes the toolbar.
  • Record keyword: names and starts a keyword.
  • Discard: drops the keyword being recorded, also from file, and returns to idle.
  • Undo: removes the Keyword Calls of the last Action.
  • Pause (two bars): stops recording until Resume; Actions in between are not recorded.
  • Pick in the header: picks an element on the page, as Record Selector does, and adds its selector to the keyword as a comment row \# Picked Selector \<selector>. Playwright’s own Pick locator button opens the same picker. While picking, nothing is recorded; Cancel returns to recording without a row.
  • Save: saves the keyword being recorded and returns to idle.

While the toolbar is minimized, its header offers Start (idle) or Save (recording).

The toolbar is idle until a keyword is started; Actions while idle are not recorded. While recording, click a value or a selector in the toolbar to turn the whole of it, or a marked part, into a Keyword Argument, named like email or ${email}. The same dialog asks whether the marked value becomes the argument’s default. The toolbar also offers to use the new argument for the same value elsewhere in the keyword (replacing repeated values).

Existing keywords are never extended.

The recording ends with ✕ in the toolbar header, with Playwright’s Record button, when idle_timeout passes without any Action or toolbar command, when all pages are closed, or on an error. The keyword being recorded is saved unless it has no Keyword Calls.

Arguments Description
file Target .robot or .resource file. Defaults to ${SUITE_SOURCE}, the file of the running suite; in a suite initialisation file that is its __init__.robot, and a keyword recorded there can only be used in that file. A relative path is resolved against the current working directory, not against the suite; use ${CURDIR} for a file next to the suite. The folder must exist and an existing file must be writable; both are checked before recording starts. With ${None} nothing is written; the keywords are logged to the console and to the log at INFO level instead.
idle_timeout Ends the recording after this long without an Action or toolbar command. Must be greater than zero. Default: 5 minutes, so a forgotten recording does not block the run for good. ${None} waits without limit.

Returns the text of all keywords recorded in the session, under one *** Keywords *** header. If a recorded keyword cannot be written - the file became read-only, the disk is full - the keyword fails, and the recorded text is logged as a warning so nothing is lost.

What is generated: every keyword gets [Tags] recorded. A popup or new tab becomes Switch Page NEW. An Action on another open page gets a Switch Page to it first, using the id the Switch Page that left that page returned (${page}= Switch Page NEW); a page closed by hand becomes Close Page, or Close Page ${page} when it is not the active one. A page the keyword has no id of, for example one open before the recording, cannot be switched to, and the toolbar says so. A dialog gets Handle Future Dialogs action=accept before the Action (Playwright does not report whether the dialog was accepted); a download is wrapped in Promise To Wait For Download and Wait For. A file chosen in a file chooser wraps the click that opened it in Promise To Upload File and Wait For; the page never reveals the file’s folder, so the path reads \<define_path_to_file>/\<file name> and must be completed (or made an argument). Playwright’s Assert snapshot becomes Get Aria Snapshot with an exact YAML comparison, and Assert visibility becomes Get Element States ... *= visible. Playwright folds a navigation that happens within 5 seconds after a click, fill or key press into that Action, so it is not recorded as a Go To of its own. Hovers are not recorded, because Playwright does not report them. Other Actions without a Browser keyword are only reported in the toolbar.

Needs a visible browser: fails if the active browser was opened headless, since nobody could use the toolbar there. A browser attached with Connect To Browser is assumed to be visible.

Limitations: only the current browser context is recorded; other contexts are ignored. Playwright’s own recorder toolbar is shown at the top centre of the page during the recording and cannot be hidden, so it covers the page there. The toolbar does not appear on a page whose Content-Security-Policy allows only Trusted Types policies it names, nor in a document without a body, such as an SVG file. A modal \<dialog> of the page covers the toolbar until it is closed, and a click there is recorded on the dialog.

Review recorded keywords before you commit them. Their values come from the page under test, including anything typed into password fields. During the session the toolbar state, including the recorded values and typed text, is readable by scripts of every page in the context, and those scripts can send toolbar commands. Keystrokes typed into the toolbar do not reach the page, except to a window capture listener the page registered before the toolbar was injected.

Requires a Playwright version that offers the programmatic recorder. The context stays prepared for recording after the session ends.

Example:

${text} = Record Keywords
Record Keywords ${CURDIR}/resources/shop.resource idle_timeout=${None}

See Record Keyword to record exactly one keyword.


label : str | None = ${None}
generator : SelectorGenerator = playwright
idle_timeout : timedelta | None = 0:05:00

Return Type: str

Tags:

  • PageContent
  • Recorder

Pick an element on the active page and return a selector for it.

Shows the Robot Framework toolbar on the active page and blocks until a selector is chosen. Move the pointer over the page: Playwright highlights the element under it and names it in a tooltip. Click to pick it; the click does not reach the page. Elements inside frames and open shadow roots can be picked too.

The toolbar then shows the selector for the picked element:

  • Playwright / CSS: switches between the selector generators for the same element, see SelectorGenerator.
  • The selector itself can be edited. The elements it finds stay highlighted on the page, and the toolbar counts them; after an edit both follow once typing pauses for a second. One match is what most keywords need, several are shown as a warning, none as an error. The highlight ends with the keyword.
  • Highlight (a dashed square): switches the highlight off and on; it is on by default.
  • Reselect: picks another element.
  • Use: returns the selector, also when it does not find exactly one element.
  • ✕ in the header, or Escape in the toolbar: cancels, and the keyword fails.
  • Minimized, the header offers Reselect and Use once an element is picked.
Arguments Description
label Shown in the toolbar header, to say which element to pick.
generator The generator the toolbar starts with; the toolbar can switch it. playwright (default) or css.
idle_timeout Fails the keyword after this long without a pick or toolbar command. Must be greater than zero. Default: 5 minutes. ${None} waits without limit.

Fails in a headless browser, while a Record Keyword or Record Keywords session runs in the browser context, when the page is closed, on cancel and when the idle_timeout passes.

The toolbar has the limits of the Record Keyword toolbar: it does not appear on a page whose Content-Security-Policy allows only Trusted Types policies it names, nor in a document without a body.

Like the recorder toolbar, the toolbar’s commands are reachable by scripts of the page under test: use it on applications you trust, and check the selector you get.

Example:

${selector} = `Record Selector` Login button
`Click` ${selector}
${heading} = `Record Selector` Page header generator=css
`Get Text` ${heading} == Expected text

Comment >>


keyword : str | None The name of a keyword that will be executed if a Browser keyword fails. It is possible to use any available keyword, including user keywords or keywords from other libraries.
*args : str The arguments to the keyword if any.
🏷scope : Scope = Global Scope defines the lifetime of this setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Return Type: DelayedKeyword

Tags:

  • Config

Sets the keyword to execute, when a Browser keyword fails.

The initial keyword to use is set when importing the library, and the keyword that is used by default is Take Screenshot fail-screenshot-{index}. Taking a screenshot when something failed is a very useful feature, but notice that it can slow down the execution.

It is possible to use string NONE or any other robot falsy name, case-insensitively, as well as Python None to disable this feature altogether.

This keyword returns an object which contains the previously registered failure keyword. The return value can always be used to restore the original value later. The returned object contains the keyword name and the possible arguments used for the keyword.

If the Take Screenshot keyword is registered as run on failure keyword without positional arguments and without the filename argument, then the default value of the filename argument is not used as screenshot file name. Instead, ${TEST NAME}_FAILURE_SCREENSHOT_{index} in the output directory is used as file name. If there is a need to use the default value of the filename argument, use robotframework-browser-screenshot-{index} as the filename argument value.

Example:

`Register Keyword To Run On Failure` Take Screenshot # Uses ${TEST NAME}_FAILURE_SCREENSHOT_{index} as filename
`Register Keyword To Run On Failure` Take Screenshot robotframework-browser-screenshot-{index} # Uses robotframework-browser-screenshot-{index} as filename
${previous kw}= `Register Keyword To Run On Failure` NONE # Disables run on failure functionality.
`Register Keyword To Run On Failure` ${previous kw}
`Register Keyword To Run On Failure` Take Screenshot fullPage=True
`Register Keyword To Run On Failure` Take Screenshot failure-{index} fullPage=True

Comment >>


timeout : timedelta | None = ${None} Maximum time for the reload to succeed. If not given, the currently set browser timeout is used.
waitUntil : PageLoadStates = load When to consider the operation succeeded, defaults to load.

Tags:

  • BrowserControl
  • Setter

Reloads current active page.

waitUntil events can be either: domcontentloaded - consider the operation to be finished when the DOMContentLoaded event is fired. load - consider the operation to be finished when the load event is fired. networkidle - consider the operation to be finished when there are no network connections for at least 500 ms. commit - consider the operation to be finished when the network response is received and the document started loading.

If the wait times out, the page’s load report is logged: whether its navigation committed, how far the document got and which requests were still open.

Comment >>


locator : str

Tags:

  • PageContent
  • Setter

Remove the locator handler indicated by locator.

The locator must be exactly the same string that was used as the selector argument when the handler was added. Handlers are tied to the page in which they were added, therefore this keyword removes the handler from the active page only. If no handler is found, the keyword does not fail, it only logs that no handler was found.


window : str | None = ${None} The window, see Windows and pages. Defaults to the window that shows the active page.

Return Type: None

Brings a maximised, minimised or fullscreen window back to its normal state and waits until it is there.

A window that was maximised before it was minimised is normal afterwards as well.

Example:

`Maximize Window`
`Restore Window`
`Get Window State` == normal

Tags:

  • Clock
  • Setter

Resumes the clock.

Once this keyword is called, time resumes flowing and timers are fired as usual.


path : Path | None = ${None} Where the state file is written. Relative paths are resolved against the current working directory and missing parent directories are created. If the file already exists, it is overwritten. If not given, a file with a generated name is created in ${OUTPUTDIR}/browser/state. The absolute path of the written file is returned.
🏷indexedDB : bool = ${False} Also save IndexedDB. Needed by applications, like Firebase, which store authentication tokens in IndexedDB.
🏷credentials : bool = ${False} Also save the context’s virtual WebAuthn credentials, as created by Create Credential. This is not related to the httpCredentials argument of New Context, which is about HTTP authentication.

Return Type: str

Tags:

  • BrowserControl
  • Getter

Saves the current active context storage state to a file.

Web apps use cookie-based or token-based authentication, where authenticated state is stored as cookies or in local storage. This keyword retrieves the storage state from authenticated contexts and saves it to disk. Then New Context can be created with prepopulated state.

Please note that the state file may contain secrets and should not be shared with people outside of your organisation.

Files in ${OUTPUTDIR}/browser/state are automatically deleted when new test execution starts. To keep a state file over several executions, save it with path to a location outside of that folder. File path is returned by the keyword.

Example:

Test Case
`New context`
`New Page` https://login.page.html
# Perform login
VAR ${username: Secret} %{USERNAME} # Convert environment variable to secret
VAR ${password: Secret} %{PASSWORD} # Convert environment variable to secret
`Fill Secret` id=username ${username}
`Fill Secret` id=password ${password}
`Click` id=button
`Get Text` id=header == Something
# Save storage to disk
${state_file} = `Save Storage State`
# Create new context with saved state
`New context` storageState=${state_file}
`New Page` https://login.page.html
# Login is not needed because authentication is read from state file
`Get Text` id=header == Something

Comment >>

In Electron applications:

Fails with Target.createTarget: Not supported when an http or https origin that the application has visited is no longer open in a window: Playwright then opens a page of its own, which Electron does not allow. The local storage of file:// pages is not saved.


selector : str | None = ${None} Selector of the element. If the selector is ${None} or ${Empty} the page itself is scrolled. To ensure an element is in view use Hover instead. See the Finding elements section for details about the selectors.
vertical : str = height Defines how far and in which direction to scroll vertically. It can be a positive or negative number. Positive scrolls down, like 50, negative scrolls up, like -50. It can be a percentage value of the absolute scrollable size, like 9.95% or negative like -10%. It can be the string height to scroll exactly one visible height down, or -height to scroll one visible height up. Be aware that some pages do lazy loading and load more content once you scroll down. The percentage of the current scrollable height is used and may change. Defaults to height.
horizontal : str = 0 Defines how far and in which direction to scroll horizontally. Works the same way as vertical, but positive values scroll to the right and negative values to the left. width scrolls exactly one visible range to the right. Defaults to 0.
behavior : ScrollBehavior = auto Defines whether the scroll happens instantly or smoothly. Defaults to auto.

Tags:

  • PageContent
  • Setter

Scrolls an element or the page relative from current position by the given values.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Comment >>


selector : str | None = ${None} Selector of the element. If the selector is ${None} or ${Empty} the page itself is scrolled. To ensure an element is in view use Hover instead. See the Finding elements section for details about the selectors.
vertical : str = top Defines where to scroll vertically. It can be a positive number, like 300. It can be a percentage value of the absolute scrollable size, like 50%. It can be a string defining the top or the bottom of the scroll area. < top | bottom > Be aware that some pages do lazy loading and load more content once you scroll down. Bottom defines the currently known bottom coordinate. Defaults to top.
horizontal : str = left Defines where to scroll horizontally. Works the same way as vertical, but defines < left | right > as start and end. Defaults to left.
behavior : ScrollBehavior = auto Defines whether the scroll happens instantly or smoothly. Defaults to auto.

Tags:

  • PageContent
  • Setter

Scrolls an element or the page to an absolute position based on given coordinates.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Comment >>


selector : str Selector of the element. See the Finding elements section for details about the selectors.

Tags:

  • PageContent
  • Setter

This method waits for actionability checks, then tries to scroll element into view, unless it is completely visible.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Does nothing if the element is already completely visible.

Comment >>


selector : str Selector of the \<select> tag. See the Finding elements section for details about the selectors.
attribute : SelectAttribute Attribute to select options by. Can be value, label, text or index. Where label and text are same.
*values Values to select.

Return Type: list[Any]

Tags:

  • PageContent
  • Setter

Selects options from select element found by selector.

Returns a list of the options which the keyword was able to select. The type of the list items matches the attribute definition. For example, if attribute equals label, the returned list contains label values. Or in case of index, it contains the selected indexes.

Keyword uses strict mode, see Finding elements for more details about strict mode.

If no values to select are passed, all options of the element are deselected. The keyword fails if none of the given values matches an option.

Example:

${selected} = `Select Options By` select[name=preferred_channel] label Direct mail
List Should Contain Value ${selected} Direct mail
${selected} = `Select Options By` select[name=interests] value males females others
List Should Contain Value ${selected} males
List Should Contain Value ${selected} females
List Should Contain Value ${selected} others
Length Should Be ${selected} 3
${selected} = `Select Options By` select[name=possible_channels] index 0 2
List Should Contain Value ${selected} 0
List Should Contain Value ${selected} 2
${selected} = `Select Options By` select[name=interests] text Males Females
List Should Contain Value ${selected} Males
List Should Contain Value ${selected} Females

Comment >>


frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the SessionStorage of that frame is used.
Example: iframe[name="test"] >>> body

Tags:

  • PageContent
  • Setter

Remove all saved data from the session storage.

Example:

`SessionStorage Set Item` mykey3 myvalue3
`SessionStorage Clear`
`SessionStorage Get Item` mykey3 == ${None}

Comment >>


key : str Named key of the item in the storage.
assertion_operator : AssertionOperator | None = ${None} Assertion operator to use. See Assertions for more information.
assertion_expected : Any | None = ${None} Expected value to compare with.
message : str | None = ${None} Custom error message to use.
frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Return Type: Any

Tags:

  • Assertion
  • Getter
  • PageContent

Get saved data from the session storage.

See Assertions for further details about the assertion arguments. They default to None.

If the key does not exist in the storage, ${None} is returned.

Example:

`SessionStorage Set Item` key2 value2
${item} = `SessionStorage Get Item` key2
Should Be Equal ${item} value2

Comment >>


key : str The name of the item which shall be deleted.
frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Tags:

  • PageContent
  • Setter

Remove saved data with key from the session storage.

Example:

`SessionStorage Set Item` mykey2 myvalue2
`SessionStorage Remove Item` mykey2
`SessionStorage Get Item` mykey2 == ${None}

Comment >>


key : str The name of the key under which it should be saved.
value : str The value which shall be saved as a string.
frame_selector : str | None = ${None} If this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Tags:

  • PageContent
  • Setter

Save data to session storage.

Example:

`SessionStorage Set Item` key2 value2

Comment >>


formatters : Dict[FormatterKeywords, list[FormatingRules | LambdaFunction]] Dictionary of keywords and formatters, where the key is the name of the keyword where the formatters are applied. The dictionary value is a list of formatters which are applied. Formatters for a defined keyword are always overwritten. An empty list will clear all formatters for the keyword. If formatters is an empty dictionary, then all formatters are cleared from all keywords, in the Global scope, regardless of the scope argument.
scope : Scope = Suite Defines the lifetime of the formatter, possible values are Global, Suite and Test.

Return Type: dict[str, list[str]]

Tags:

  • Config

Set keywords formatters for assertions.

Returns the formatters which were in use before this keyword was called. Formatters defined as lambda functions are not included in the returned value.

See type documentation of FormatterKeywords and FormatingRules for more information.

It is possible to define own formatters as lambda functions.

Example:

`Set Assertion Formatters` {"Get Text": ["strip", "normalize spaces"]} # This will convert all kinds of spaces to a single space and remove spaces from the start and end of the string.
`Set Assertion Formatters` {"Get Title": ["apply to expected","lambda x: x.replace(' ', '')"]} # This will remove all spaces from the string.
${value} = `Get Text` //div == ${SPACE}Expected${SPACE * 2}Text
Should Be Equal ${value} Expected Text

Comment >>


timeout : timedelta The timeout is set for the current Playwright context and for new contexts. Supports Robot Framework time format.
scope : Scope = Suite Scope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Return Type: str

Tags:

  • Config
  • Setter

Sets the timeout used by most input and getter keywords.

Returns the previous value of the timeout.

Example:

${old_timeout} = `Set Browser Timeout` 1m 30 seconds
Click //button
`Set Browser Timeout` ${old_timeout}

Close Browser and Close Context are not shortened by this setting; they always get at least 20 seconds.

Comment >>


runBeforeUnload : bool

Return Type: bool

Tags:

  • BrowserControl
  • Setter

Set default runBeforeUnload value when Close Page is called indirectly.

Close Page is called indirectly when automatic page closing is done. The default value is false and this keyword can be used to change value. Returns the old runBeforeUnload value.

Comment >>


latitude : float Latitude between -90 and 90.
longitude : float Longitude between -180 and 180.
accuracy : float | None = ${None} Non-negative accuracy value. Defaults to 0.

Tags:

  • BrowserControl
  • Setter

Updates the current context’s geolocation.

Latitude can be between -90 and 90 and longitude can be between -180 and 180. The accuracy of the location must be a non-negative number and defaults to 0. When creating the context, grant the geolocation permission so that pages can read the geolocation.

Example:

${permissions} = Create List geolocation
`New Context` permissions=${permissions}
`Set Geolocation` 60.173708 24.982263 3 # Points to Korkeasaari in Helsinki.

Comment >>


highlight : bool = ${True} If True, the element is highlighted when a screenshot is taken on failure. If False, the element is not highlighted in the screenshot.
scope : Scope = Suite Scope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Return Type: bool

Tags:

  • Config
  • Setter

Controls if the element is highlighted on failure.

Returns the previous value of the setting.

Example:

`Set Highlight On Failure` True

Comment >> #TODO add real link


offline : bool = ${True} Toggles the offline mode. Set to False to switch back to online mode. Defaults to True.

Tags:

  • BrowserControl
  • Setter

Toggles the current context’s offline emulation.

Comment >>


mode : HighLightElement | bool When set to True, enables presenter mode with default settings. When set to False, disables presenter mode. Can also be a dictionary containing the highlighting configuration options as defined in HighLightElement. Fields which are not given use their default values: duration 2 seconds, width 2px, style dotted and color blue.

Return Type: HighLightElement | bool

Tags:

  • BrowserControl
  • Setter

Sets presenter mode for element highlighting during test execution.

Presenter mode highlights elements found by keywords, which is useful for test debugging and demonstration. When enabled, the element is scrolled into view and highlighted with a border for a while to visually show what the keyword found.

The keyword returns the previous presenter mode value, allowing you to restore it later.

Example:

${old_mode} = Set Presenter Mode True
Click //button # Element will be highlighted
Set Presenter Mode ${old_mode} # Restore previous mode
# With custom highlighting configuration
VAR &{config}
... duration=5 seconds
... width=3px
... style=dotted
... color=red
Set Presenter Mode ${config}
Get Text //input # Will use custom highlight settings
Set Presenter Mode False # Turn off highlighting

timeout : timedelta Assertion retry timeout will determine how long Browser library will retry an assertion to be true.
scope : Scope = Suite Scope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Return Type: str

Tags:

  • Config
  • Setter

Sets the timeout used in retrying assertions when they fail.

The other keyword Set Browser Timeout controls how long Playwright will wait on the node side for elements to fulfill the requirements of the specific keyword.

Returns the previous value of the assertion retry timeout.

Example:

`Set Browser Timeout` 10 seconds
${old} = `Set Retry Assertions For` 30s
`Get Title` == Login Page
`Set Retry Assertions For` ${old}

The example waits 10 seconds in Playwright to get the page title and the library will retry for 30 seconds to make sure that the title is correct.

Comment >>


prefix : str | None Prefix for all selectors. Prefix and selector will be separated by a single space. Use ${None} or ${EMPTY} to disable the prefix.
scope : Scope = Suite Scope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Return Type: str

Tags:

  • Config
  • Setter

Sets the prefix for all selectors in the given scope.

Returns the previous value of the prefix.

Example:

${old} = `Set Selector Prefix` iframe#embedded_page >>>
`Click` button#login_btn # Clicks on button inside iframe with the selector ``iframe#embedded_page >>> button#login_btn``
`Set Selector Prefix` ${old}

Example will click on button with id login_btn inside iframe with id embedded_page. The resulting selector will be iframe\#embedded_page >>> button\#login_btn.

The effect of this prefix can be disabled by prefixing any selector with !prefix , with a trailing space, for single keyword calls, i.e. !prefix id=btn_outside_a_frame

Get Element, Get Elements, Get Element By and Get Element By Role automatically prefix the returned selector with !prefix so that it is possible to use them directly without setting the prefix to ${None} before usage.

Comment >>


mode : bool When set to True, keywords that search elements will use Playwright strict mode and fail if the selector matches more than one element. When set to False, such keywords do not fail but operate on the first matching element.
scope : Scope = Suite Scope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Tags:

  • BrowserControl
  • Setter

Controls library strict mode.

The keyword returns the strict mode value which was in use before this keyword was called.

Strict mode is enabled by default. The initial value can also be set with the strict argument in the library importing. Strict mode is applied only to those keywords which state in their documentation that they use strict mode, see Finding elements for more details.

Example:

${old_mode} = Set Strict Mode False
Get Text //input # Does not fail even if the selector matches multiple elements
Set Strict Mode ${old_mode}

Comment >>


time : datetime The time to set. Supports Robot Framework date and time format
clock_type : ClockType = install The clock type to set. Default is install.

Tags:

  • Clock
  • Setter

Sets the time of the browser’s internal clock.

fixed makes Date.now and new Date() always return the same fake time, while all timers keep running.

system sets the current system time but does not trigger any timers.

install installs fake timers, which are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and control the behavior of time-dependent functions.

How to use clock related keywords, see Playwright clock documentation. Also reviewing the Playwright Clock API is recommended.


width : int Sets the width in pixels.
height : int Sets the height in pixels.

Tags:

  • BrowserControl
  • Setter

Sets the current page’s viewport size to the specified dimensions.

In the case of multiple pages in a single browser, each page can have its own viewport size. However, New Context allows setting the viewport size (and more) for all later opened pages in the context at once.

Set Viewport Size will resize the page. A lot of websites don’t expect phones to change size, so you should set the viewport size with New Context before opening the page itself.

Comment >>


width : int The width of the content in pixels.
height : int The height of the content in pixels.
window : str | None = ${None} The window, see Windows and pages. Defaults to the window that shows the active page.

Return Type: None

Raises:

  • AssertionError: The window does not get the size within the library timeout, for example because the screen is smaller. The error names the size that the window has.

Gives a window the content size width x height and waits until it has it.

The content size is the area that the window’s page shows, which its screenshots and its video have as well. A maximised, minimised or fullscreen window is made normal first. At a fractional display scale, the size can be off by up to 2 pixels, because the window’s edges snap to whole device pixels.

Example:

`Set Window Size` 1280 720
`Set Window Size` 1024 700 title=Settings

show : bool = ${True} If True, the banner is shown on the page. If False, the banner is not shown on the page. If ${None}, the banner is shown on the page only when running in presenter mode.
style : str = ${EMPTY} Additional CSS styles to be applied to the banner. These styles may override the existing ones for the banner.
scope : Scope = Suite Scope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Setting for more details.

Return Type: dict[str, bool | str | None]

Tags:

  • Config
  • Setter

Controls if the keyword banner is shown on page or not.

The keyword call banner is a CSS overlay that shows the currently executed keyword directly on the page. This is useful for debugging and for showing the test execution on video recordings. By default, the banner is not shown on the page except when running in presenter mode.

The banner can also be controlled by an import setting of the Browser library. (see Importing section)

Returns the previous settings as a dictionary with the keys show and style.

Example:

Show Keyword Banner True top: 5px; bottom: auto; left: 5px; background-color: #00909077; font-size: 9px; color: black; # Show banner on top left corner with custom styles
Show Keyword Banner False # Hide banner

Comment >>


🏷config_file : PathLike | None = ${None} Optional path to options file. If the file does not exist, it is ignored.
🏷coverage_type : CoverageType = all Type of coverage to start. Default is all.
🏷path : Path = . Absolute or relative directory path (relative to ${OUTPUT_DIR}/browser/coverage/) where the coverage is stored in a directory with the page id name.
🏷raw : bool = ${False} Whether to save raw coverage data. Default is False.
🏷reportAnonymousScripts : bool = ${False} Whether to report anonymous scripts. Default is False. Only valid for JS coverage.
🏷resetOnNavigation : bool = ${True} Whether to reset coverage on navigation. Default is True.

Return Type: str

Tags:

  • Coverage
  • Experimental
  • Setter

Starts the coverage for the current page.

The coverage_type can be one of the following:

Coverage must be started when the page is open and before any action is performed on the page. Coverage will be stored when calling the Stop Coverage keyword or when the page or context is closed. This is done automatically when using the auto closing.

The raw argument saves the raw coverage data in the coverage folder. The raw data is needed to combine multiple coverage reports into a single report. A single report can be created with the rfbrowser coverage /path/to/basefolder/ /path/to/outputfolder/ command. Please note that the raw argument is ignored if the config_file is defined. In that case the user is responsible for also setting the raw reporter in the config file. To see more details about combining coverage data, run the rfbrowser coverage --help command.

Example:

`New Page`
`Start Coverage`
`Go To` ${LOGIN_URL}
Do Something In The Page
`Stop Coverage`

executable_path : Path The Electron executable, as a path or as a command found on PATH. A relative path is relative to the working directory of the test run. For an app that is run by the plain Electron binary, pass the app folder in args.
args : list[str] | None = ${None} Command-line arguments for the application.
env : dict[str, str] | None = ${None} Environment variables of the application. If not given, the application gets the environment of the test run without ELECTRON_RUN_AS_NODE, which runs started from VS Code have and which would make Electron run as plain Node.js.
cwd : Path | None = ${None} Working directory of the application. A relative path is relative to the working directory of the test run, which is also the default.
timeout : timedelta | None = ${None} How long to wait for the application to start and open its first window. Defaults to the library timeout.
record_video : RecordVideo | None = ${None} Records a video of the application’s windows, see RecordVideo for the folder, size, frame rate and the annotations of the performed actions. An empty dictionary records with the defaults: Browser’s video folder browser/video in the output directory and a size of 1280x720. A larger window is scaled down to fit, a smaller one is shown at its own size with a grey margin. The log embeds the video, and the file is complete once the application has closed. Recording needs Playwright’s ffmpeg, which comes with any browser that Browser installs, but not with rfbrowser init --skip-browsers.
record_har : RecordHar | None = ${None} Records the network traffic of the application’s windows into a HAR file, as recordHar of the Browser library’s New Context: a dictionary with the path of the file and optionally omitContent. A relative path is relative to the output directory. The file is written when the application closes.
tracing : bool | Path | None = ${None} Records a Playwright trace of the application, as tracing of the Browser library’s New Context: True saves it in browser/traces in the output directory, named after the application’s context, and a *.zip path or a folder saves it there. Give a path to know the file’s name. The variable or environment variable ROBOT_FRAMEWORK_BROWSER_TRACING set to True traces every application. The trace is saved when the application closes and shows the keyword calls as groups. Open it with rfbrowser show-trace /path/to/trace.zip.
color_scheme : ColorScheme | None = ${None} The color scheme that the windows report for prefers-color-scheme: light or dark. By default, and with null, the application decides, as it does outside of tests. Set it for tests that compare screenshots, so that they look the same on every machine.
locale : str | None = ${None} The locale of the windows, for example de-DE. It sets the language that the pages report and their number and date formats. Defaults to the system’s. The main process keeps the system’s locale; --lang in args sets it there.
timezone_id : str | None = ${None} The time zone of the windows, for example Europe/Berlin. Defaults to the system’s. The main process keeps the system’s time zone; TZ in env sets it there.
bypass_csp : bool = ${False} Bypasses the Content Security Policy of the windows, including Trusted Types, as bypassCSP of the Browser library’s New Context. Features that add scripts to a page need it in applications with a strict policy, for example Record Selector in VS Code. An application can load its first window before the option takes effect, so the keyword loads the windows that are open once more. It also applies to webviews and frames, so that policy problems of the application go unnoticed. Switch it on only where a feature needs it.

Return Type: tuple[str, NewPageDetails] — A tuple of the application id and the page details of the first window. The page details contain the page id and the path of the video, or an empty string if no video is recorded.

Raises:

  • ValueError: The executable is not found.

Starts an Electron application and makes its first window the active page.

The application becomes the active application. Its windows are pages, so Browser keywords like Click and Get Text work on them, and windows the application opens later can be selected with Switch Window. Close Electron Application and automatic closing end the application.

Example:

${app} ${page} = `Start Electron Application` /opt/my-app/my-app
`Get Title` == My App
`Start Electron Application` ${ELECTRON} args=${{ [$EXECDIR + "/app"] }}
`Start Electron Application` /opt/my-app/my-app tracing=True record_har={'path': 'my-app.har'}
`Start Electron Application` /opt/my-app/my-app color_scheme=dark locale=de-DE
`Start Electron Application` /opt/my-app/my-app record_video={'showActions': {'position': 'bottom'}}

Return Type: Path | None

Tags:

  • Coverage
  • Getter

Stops the coverage for the current page.

Creates a coverage report by using monocart-coverage-reports To see the default and all possible options, see options.js file for more details.

If coverage was not started, the keyword returns None. Otherwise it returns the path to the generated HTML report file, or the path to the coverage folder if no HTML file is found from the folder. The latter can happen when the report format or output folder has been changed with the config_file argument of the Start Coverage keyword.


application : str The application id that Start Electron Application returned.

Return Type: str — The id of the application that was active before.

Makes another open application the active one.

Browser keywords then act on the active page of that application.

Example:

${first} ${_} = `Start Electron Application` /opt/my-app/my-app
`Start Electron Application` /opt/other-app/other-app
`Switch Electron Application` ${first}

id : NewPageDetails | SelectionType | str The id or alias of the page to switch to. Example: page=8baf2991-5eaf-444d-a318-8045f914e96a or NEW. Can be a string or a dictionary returned by New Page Keyword. A page id can be fetched from the browser catalog when returned by Get Browser Catalog. NEW can be used to switch to a pop-up that just has been opened by the webpage, CURRENT can be used to switch to the active page of a different context or browser, identified by their id.
context : SelectionType | str = CURRENT The context in which to search for that page. CURRENT for the currently active context, ALL to search in all open contexts or the id of the context where to switch page.
browser : SelectionType | str = CURRENT The browser in which to search for that page. CURRENT for the currently active browser, ALL to search in all open browsers or the id of the browser where to switch page.

Return Type: str

Tags:

  • BrowserControl
  • Setter

Switches the active browser page to another open page by id or NEW.

Returns a stable identifier id for the previous page. See Browser, Context and Page for more information about Page and related concepts.

If a page id is given, the context and browser arguments are ignored and the page is searched from all open browsers.

NEW may time out if no new page is opened before the library timeout expires.

Example:

`Click` button#pops_up # Open new page
${previous} = `Switch Page` NEW

Comment >>

In Electron applications:

Each window of an application is a page, and so are the \<webview> and WebContentsView elements it shows. NEW takes the newest page if it is newer than the active page, which can be a \<webview> that loaded after a new window. Switch Window switches to a window by its title instead. Select a \<webview> or WebContentsView by its page id, which Get Electron Application Catalog returns with its title. browser takes an application id.


window : str The window, as title=\<title>, as a regular expression title=/\<pattern>/\<flags> or as an id from Get Window Ids, see Windows and pages, or the page id of its page, as Switch Page takes it, or NEW for the newest page. A title suits a window that the application opens best, because the keyword waits until the window shows it. NEW takes the newest page if it is newer than the active page, as Switch Page does: that can be a \<webview> that loaded after the window, or after a switch back to an older window, a page that was open before.

Return Type: str — The id of the page that was active before. Switch Window and Switch Page switch back to it.

Raises:

  • AssertionError: No window matches, or the page is not a window’s own page. The active page then stays the same. For a title, an expression or a window id, the keyword finds the window’s page in Browser’s catalog by the page’s title, so the page needs a title that no other page of the application has. Otherwise, switch with the page id.

Makes the own page of a window the active page and returns the id of the page that was active before.

Browser keywords then act on that page, and the window comes to the front. Switch Page does the same for any page; Switch Window switches only to windows and fails instead of switching to a \<webview> or WebContentsView.

Example:

`Click` text=Settings
${previous} = `Switch Window` title=Settings
`Click` text=Save
`Switch Window` ${previous}

filename : str | None = robotframework-browser-screenshot-{index} Filename into which to save. The file will be saved into the Robot Framework ${OUTPUTDIR}/browser/screenshot directory by default, but it can be overwritten by providing a custom path or filename. String {index} in the filename will be replaced with a rolling number. Use this to not overwrite filenames. If filename equals to UUID (case insensitive), then the filename is created by Python uuid; https://docs.python.org/3/library/uuid.html. If filename equals to EMBED (case insensitive) or ${NONE}, then the screenshot is embedded as a Base64 image into the log.html. The image is saved temporarily to the disk and a warning is displayed if removing the temporary file fails. The ${OUTPUTDIR}/browser/screenshot directory is removed at the first suite startup.
selector : str | None = ${None} Take a screenshot of the element matched by selector. See the Finding elements section for details about the selectors. If not provided, take a screenshot of the current viewport.
🏷crop : BoundingBox | None = ${None} Crops the taken screenshot to the given box. It takes the same dictionary as returned from Get BoundingBox. Cropping only works on a page screenshot, so when no selector is given.
🏷disableAnimations : bool = ${False} When set to True, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration: - finite animations are fast-forwarded to completion, so they’ll fire the transitionend event. - infinite animations are cancelled to initial state, and then played over after the screenshot.
🏷fileType : ScreenshotFileTypes = png png or jpeg. Specifies the screenshot type, defaults to png.
🏷fullPage : bool = ${False} When True, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to False.
🏷highlight_selector : str | None = ${None} Highlights elements while taking the screenshot. Highlight method is playwright. This highlighting also automatically happens if the Robot Framework variable ${ROBOT_FRAMEWORK_BROWSER_FAILING_SELECTOR} is set to a selector string and is available on page. This is the case if highlight_on_failure has been set to True when importing Browser library.
🏷log_screenshot : bool = ${True} When set to False the screenshot is taken but not logged into log.html.
🏷mask : list[str] | str = ${EMPTY} Specify selectors that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box \#FF00FF that completely covers their bounding box. The argument can take a single selector string or a list of selector strings if multiple different elements should be masked.
🏷maskColor : str | None = ${None} Specify the color of the overlay box for masked elements, in CSS color format. Default color is pink #FF00FF.
🏷omitBackground : bool = ${False} Hides the default white background and allows capturing screenshots with transparency. Not applicable to jpeg images.
🏷quality : int | None = ${None} The quality of the image, between 0-100. Not applicable to png images.
🏷scale : Scale | None = ${None} css or device. css will reduce the image size and device keeps the image in its original size. Defaults to device.
🏷return_as : ScreenshotReturnType = path_string Defines what this keyword returns. Possible values are documented in ScreenshotReturnType. It can be either a path to the screenshot file as string or Path object, or the image data as bytes or base64 encoded string. When the screenshot is embedded into the log, path_string returns the string EMBED.
🏷timeout : timedelta | None = ${None} Maximum time how long taking the screenshot can last, defaults to the library timeout. Supports Robot Framework time format, like 10s or 1 min, pass 0 to disable the timeout. The default value can be changed by using the Set Browser Timeout keyword.

Return Type: str | bytes | Path | None

Tags:

  • PageContent

Takes a screenshot of the current window or element and saves it to disk.

Keyword uses strict mode if selector is defined. See Finding elements for more details about strict mode.

Example

`Take Screenshot` # Takes screenshot from page with default filename
`Take Screenshot` selector=id=username_field # Captures element in image
# Takes screenshot with jpeg extension, defines image quality and timeout how long taking screenshot should last
`Take Screenshot` fullPage=True fileType=jpeg quality=50 timeout=10s
`Take Screenshot` EMBED # Screenshot is embedded as Base64 image to the log.html.
`Take Screenshot` UUID # Takes screenshot from page with filename generated by: https://docs.python.org/3/library/uuid.html.

Comment >>


selector : str Selector of the text field. See the Finding elements section for details about the selectors.
secret : str | Secret Supports Robot Framework 7.4 Secret type as normal variable (with curly braces). Also environment variable name with % prefix or a local variable with $ prefix that has the secret text value (without curly braces).
delay : timedelta = 0:00:00 Delay between the single key strokes. It may be either a number or a Robot Framework time string. Time strings are fully explained in an appendix of Robot Framework User Guide. Defaults to 0 ms. Example: 50 ms
clear : bool = ${True} Set to False if the field should not be cleared before typing. Defaults to True.

Tags:

  • PageContent
  • Setter

Types the given secret into the text field found by selector.

This keyword does not log the secret in Robot Framework logs, but if Playwright debug logs are enabled, the secret will be visible as plain text in the Playwright debug logs, regardless of the Robot Framework log level or how secret is resolved.

This keyword supports Robot Framework 7.4 Secret variable type, which is the recommended way if you are using Robot Framework 7.4 or newer.

For older Robot Framework versions the keyword supports resolving secrets from environment variables and Robot Framework variables in the following ways. The keyword resolves the secret from a Robot Framework variable internally, when the secret variable is prefixed with $, without the curly braces. Example: $Password will resolve to the ${Password} Robot Framework variable.

If the secret variable is prefixed with %, the library will resolve the corresponding environment variable. Example: %ENV_PWD will resolve to the %{ENV_PWD} environment variable.

Using normal Robot Framework variables like ${password}, which are not Secret type variables, will not work!

Normal plain text will not work. If you want to use plain text, use the Type Text keyword instead.

This keyword also works with a cryptographic cipher text that has been encrypted by CryptoLibrary. See CryptoLibrary for more details.

Keyword uses strict mode, see Finding elements for more details about strict mode.

See Type Text for details.

Example

`Type Secret` input#username_field ${username} # Keyword resolves ${username} variable value from Robot Framework Secret type variable
`Type Secret` input#username_field $username # Keyword resolves ${username} variable value from Robot Framework variables
`Type Secret` input#username_field %username # Keyword resolves $USERNAME/%USERNAME% variable value from environment variables

Comment >>


selector : str Selector of the text field. See the Finding elements section for details about the selectors.
txt : str Text for the text field.
delay : timedelta = 0:00:00 Delay between the single key strokes. It may be either a number or a Robot Framework time string. Time strings are fully explained in an appendix of Robot Framework User Guide. Defaults to 0 ms. Example: 50 ms
clear : bool = ${True} Set to False if the field should not be cleared before typing. Defaults to True.

Tags:

  • PageContent
  • Setter

Types the given txt into the text field found by selector.

Sends a keydown, keypress/input, and keyup event for each character in the text.

Keyword uses strict mode, see Finding elements for more details about strict mode.

See Fill Text for filling the full text at once.

Example

`Type Text` input#username_field user
`Type Text` input#username_field user delay=10 ms clear=No

Comment >>


selector : str Selector of the checkbox. See the Finding elements section for details about the selectors.
force : bool = ${False} Set to True to skip Playwright’s Actionability checks.

Tags:

  • PageContent
  • Setter

Unchecks the checkbox found by selector.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Does nothing if the element is not checked/selected.

Comment >>


selector : str Identifies the file input element.
path : PathLike | FileUploadBuffer Path to the file or folder to be uploaded. Can also be a FileUploadBuffer dictionary.
*extra_paths : PathLike Additional paths to files or folders to be uploaded.

Tags:

  • PageContent
  • Setter

Uploads file from path to file input element matched by selector.

Fails if the upload is not done before the library timeout. Therefore it may be necessary to increase the timeout with Set Browser Timeout. It is possible to upload multiple files or folders by defining additional files or folders in extra_paths.

If a path is a directory, all files from the directory are uploaded. Subdirectories are not included. It is possible to upload files and directories with the same keyword. The keyword fails if a given path does not exist.

Keyword uses strict mode, see Finding elements for more details about strict mode.

If path is a FileUploadBuffer dictionary, then the structure should be:

{
'name': ``str``,
'mimeType': ``str``,
'buffer': ``str``
}

If path argument is FileUploadBuffer, then extra_paths argument is not supported and using it will raise an error.

Upload single file example:

`Upload File By Selector` //input[@type='file'] big_file.zip

Upload many files example:

`Upload File By Selector` //input[@type='file'] file1.zip file2.zip file3.zip

Upload folder example:

`Upload File By Selector` //input[@type='file'] /path/to/folder

Upload as buffer example:

${text} = Get File /path/to/file # Read file from disk
VAR &{buffer} name=not_here.txt mimeType=text/plain buffer=${text} # Create buffer dictionary
`Upload File By Selector` id=file_chooser ${buffer} # Upload buffer

Comment >>


*promises : Future Promises to wait for.

Tags:

  • Wait

Waits for promises to finish and returns results from them.

Returns a single result if only one promise is waited for. Otherwise it returns a list of results in the same order as the promises were given. If one of the promises fails, then this keyword will fail.

See Promise To for more information about promises.

For general waiting of elements please see Implicit waiting.

Example:

${promise}= `Promise To` `Wait For Response` matcher= timeout=3
`Click` \#delayed_request
${body}= `Wait For` ${promise}

Comment >>


action : DialogAction How to handle the alert. Can be accept or dismiss.
prompt_input : str = ${EMPTY} The value to enter into the prompt. Only valid if the action argument equals accept. Defaults to an empty string.
text : str | None = ${None} Optional text to verify the dialog text with.
timeout : timedelta | None = ${None} Optional timeout in Robot Framework time format. Defaults to the library timeout.

Tags:

  • PageContent
  • Wait

Returns a promise to wait for next dialog on page, handles it with action and optionally verifies the dialogs text.

Dialog/alert can be any of alert, beforeunload, confirm or prompt.

The main difference between this keyword and Handle Future Dialogs is that the Handle Future Dialogs keyword is automatically set as a promise, but this keyword must be called as an argument to the Promise To keyword. Also this keyword can optionally verify the dialog text and returns it. If the text argument is None or is not set, the dialog text is not verified.

Example with returning text:

${promise} = `Promise To` `Wait For Alert` action=accept
`Click` id=alerts
${text} = `Wait For` ${promise}
Should Be Equal ${text} Am an alert

Example with text verification:

${promise} = `Promise To` Wait For Alert action=accept text=Am an alert
Click id=alerts
${text} = `Wait For` ${promise}

Comment >>


actions : list[DialogAction] List of how to handle the alerts. Can be accept or dismiss.
prompt_inputs : list[str | None] List of the values to enter into the prompts. Only valid if the corresponding action equals accept. Use None if no input is needed.
texts : list[str | None] List of optional texts to verify the dialog texts with. Use None if text verification should be disabled.
timeout : timedelta | None = ${None} Optional timeout in Robot Framework time format. Defaults to the library timeout. The timeout is applied to each alert separately.

Return Type: list[str]

Tags:

  • PageContent
  • Wait

Returns a promise to wait for multiple dialogs on a page.

Handles each alert/dialog with actions and optionally verifies the dialog texts. Dialog/alert can be any of alert, beforeunload, confirm or prompt.

There must be an equal amount of items in the actions, prompt_inputs and texts lists. Use None if texts and/or prompt inputs are not needed.

This keyword works in the same way as Wait For Alert, but it can handle multiple alerts with one promise. Like the Wait For Alert keyword, this keyword must be called as an argument to the Promise To keyword.

Example to handle two alerts, first one is accepted and second one is dismissed:

${promise} = Promise To
... Wait For Alerts
... ["accept", "dismiss"]
... [None, None]
... [None, None]
Click id=alerts
${texts} = Wait For ${promise}

Example to handle confirm and prompt alert. Example assumes that the first is a confirm and second one is prompt:

${promise} = Promise To
... Wait For Alerts
... ["dismiss", "accept"]
... [None, "I am a prompt"]
... ["First alert accepted?", None]
Click id=confirmAndPrompt
${texts} = Wait For ${promise}

Comment >>


Tags:

  • Wait

Waits for all promises to finish.

Waits for all promises which have been created but not yet waited for with Wait For. If one of the promises fails, then this keyword will fail.

Example:

`Promise To` Wait For Response matcher= timeout=3
`Click` \#delayed_request
`Wait For All Promises`

Comment >>


condition : ConditionInputs A condition, defined with Browser getter keywords, without the word Get.
*args : Any Arguments to pass to the condition keyword.
🏷timeout : timedelta | None = ${None} Timeout to wait for the condition to become True. Uses default timeout of the library if not set. As the other assertion keywords this timeout only influences the time the assertion is retried. The browser timeout is used to wait for the element to be found.
🏷message : str | None = ${None} Overrides the default error message.

Return Type: Any

Tags:

  • PageContent
  • Wait

Waits for a condition, defined with Browser getter keywords, to become True.

This keyword is basically just a wrapper around our assertion keywords, but with a timeout. It can be used to wait for anything that also can be asserted with our keywords.

In comparison to Robot Framework’s Wait Until Keyword Succeeds this keyword is more readable and easier to use, but is limited to Browser library’s assertion keywords.

The easiest way to use this keyword is first starting with an assertion keyword with assertion like: Get Text

Start:

`Get Text` id=status_bar contains Done

Then you replace the word Get with Wait For Condition and if necessary add the timeout argument.

End:

`Wait For Condition` Text id=status_bar contains Done

Example usage:

`Wait For Condition` Element States id=cdk-overlay-0 == detached
`Wait For Condition` Element States //h1 contains visible editable enabled timeout=2 s
`Wait For Condition` Title should start with Robot
`Wait For Condition` Url should end with robotframework.org

Comment >>


selector : str Selector of the corresponding object. See the Finding elements section for details about the selectors.
state : ElementState = ${<ElementState.visible: 4>} See ElementState for explanation.
timeout : timedelta | None = ${None} uses default timeout from library if not set.
message : str | None = ${None} overrides the default error message. The message argument accepts {selector}, {function}, and {timeout} format options. The {function} formatter is the state argument value for the states which are waited for by Playwright, that are attached, detached, visible, hidden, stable, enabled, disabled and editable. For all other states, it is the JavaScript expression which is evaluated for the element.

Tags:

  • PageContent
  • Wait

Waits for the element found by selector to satisfy state option.

Note that Browser library has Implicit waiting mechanisms. Depending on the situation you might not need to use Wait for Elements State.

If users experience reliability issues with this keyword, consider using Wait for Condition with Get Element States keyword instead. Wait For Elements State uses features of Playwright to wait for element states. However, in some situations these features might not work as expected. Wait for Condition with Get Element States is more robust as it uses Browser library’s own waiting mechanisms that actively poll the state of an element.

State options are appearing in or disappearing from the DOM, becoming visible or hidden, and the other states listed in ElementState. If at the moment of calling the keyword, the selector already satisfies the condition, the keyword will return immediately.

If the selector doesn’t satisfy the condition within the timeout the keyword will FAIL.

The states focused and defocused are not supported with iframe selectors, which contain >>>. In that case the keyword raises an error and suggests to use Wait For Condition with Get Element States instead.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example:

`Wait For Elements State` //h1 visible timeout=2 s
`Wait For Elements State` //h1 focused 1s

Comment >>


function : str A valid javascript function or a javascript function body. For example () => true and true will behave similarly.
selector : str = ${EMPTY} Selector to resolve and pass to the JavaScript function. This will be the first argument the function receives. If a selector is given, function must be a function with an argument which receives the element handle. For example (element) => document.activeElement === element. See the Finding elements section for details about the selectors.
polling : str | timedelta = raf Default polling value of raf polls in a callback for requestAnimationFrame. Any other value for polling will be parsed as a Robot Framework time for the interval between polls.
timeout : timedelta | None = ${None} Uses default timeout of the library if not set.
message : str | None = ${None} overrides the default error message. The message argument accepts {selector}, {function}, and {timeout} format options.

Tags:

  • PageContent
  • Wait

Polls JavaScript expression or function in browser until it returns a (JavaScript) truthy value.

Keyword uses strict mode, see Finding elements for more details about strict mode.

Example usage:

${promise} `Promise To` `Wait For Function` element => element.style.width=="100%" selector=\#progress_bar timeout=4s
`Click` \#progress_bar
`Wait For` ${promise}

Comment >>


state : PageLoadStates = load State to wait for, defaults to load. Possible values are load, domcontentloaded, networkidle and commit.
timeout : timedelta | None = ${None} Timeout supports Robot Framework time format. Uses browser timeout if not set.

Tags:

  • PageContent
  • Wait

Waits until the page reaches the required load state.

This resolves when the page reaches a required load state, load by default. The navigation must have been committed when this method is called. If current document has already reached the required state, resolves immediately.

If the state has been already reached while loading current document, the underlying Playwright will resolve immediately. Can be one of:

``load`` - wait for the load event to be fired.
``domcontentloaded`` - wait for the DOMContentLoaded event to be fired.
``networkidle`` - DISCOURAGED wait until there are no network connections for at least 500 ms.
``commit`` - not supported by this keyword, the keyword returns immediately without waiting.

If the wait times out, the page’s load report is logged: whether its navigation committed, how far the document got and which requests were still open.

Example:

`Go To` ${URL}
`Wait For Load State` domcontentloaded timeout=3s

url : str | RegExp Expected navigation target address, either a Glob-Pattern (a plain string without wildcards matches exactly) or a JavaScript-like regex wrapped in / symbols.
timeout : timedelta | None = ${None} Timeout supports Robot Framework time format. Uses default timeout if not set.
wait_until : PageLoadStates = load When to consider the operation succeeded, defaults to load. Events can be either: domcontentloaded - consider operation to be finished when the DOMContentLoaded event is fired. load - consider operation to be finished when the load event is fired. networkidle - consider operation to be finished when there are no network connections for at least 500 ms. commit - consider operation to be finished when network response is received and the document started loading.

Tags:

  • HTTP
  • Wait

Waits until the page has navigated to the given url.

The keyword works only when the page is loaded and it does not work if only the URL fragment changes. Example: if https://marketsquare.github.io/robotframework-browser/Browser.html changes to https://marketsquare.github.io/robotframework-browser/Browser.html#Wait%20For%20Navigation the keyword will fail.

Example:

`Go To` ${ROOT_URL}/redirector.html
`Wait for navigation` ${ROOT_URL}/posted.html wait_until=${wait_until}

If the wait times out, the page’s load report is logged: whether its navigation committed, how far the document got and which requests were still open.

Comment >>


matcher : str | RegExp = ${EMPTY} Request URL matcher. Can be a string (Glob-Pattern), a JavaScript RegExp (enclosed in / with optional trailing flags) or a JavaScript arrow-function that receives the Request object and returns a boolean. By default (with an empty string) the first request is matched. For additional information, see the Playwright waitForRequest documentation.
timeout : timedelta | None = ${None} Timeout supports Robot Framework time format. Uses default timeout if not set.

Return Type: DotDict | Any

Tags:

  • HTTP
  • Wait

Waits for a request matching matcher to be made.

Only the request is awaited, not its response. See Wait For Response if the response is needed.

The returned object is a dictionary with the keys url, method, headers and postData. headers is a dictionary of request headers. postData is None if the request has no body, a dictionary if the body is valid JSON and otherwise the body as a string.

See Wait For Response for more details about the matcher.

CAUTION: Before Browser library 17.0.0, the matcher argument was always either a regex or JS function. But the regex did not need to be in slashes. The most simple way to migrate to the new syntax is to add slashes around the matcher. So /api/get/json becomes //api/get/json/.

Comment >>


matcher : str | RegExp = ${EMPTY} Response URL matcher. Can be a string (Glob-Pattern), a JavaScript RegExp (enclosed in / with optional trailing flags) or a JavaScript arrow-function that receives the Response object and returns a boolean. By default (with an empty string) the first response is matched. For additional information, see the Playwright page.waitForResponse documentation.
timeout : timedelta | None = ${None} Timeout supports Robot Framework time format. Uses default timeout if not set.

Return Type: DotDict | Any

Tags:

  • HTTP
  • Wait

Waits for a response matching matcher and returns the response as a Robot Framework dictionary.

The keyword waits until the response headers are received and then reads the response body.

The response, which is returned by this keyword, is a Robot Framework dictionary with the following attributes:

  • status <int> The status code of the response.
  • statusText <str> Status text corresponding to status, e.g. OK or INTERNAL SERVER ERROR. This may not be available for all browsers.
  • body <dict | str> The response body. If the body can be parsed as a JSON object, it will be returned as Python dictionary, otherwise it is returned as a string. It is None if the body could not be read and the key is missing altogether if the response body is empty.
  • headers <dict> A dictionary containing all response headers.
  • ok <bool> Whether the request was successful, i.e. the status is in the range 200-299.
  • request <dict> containing method <str>, headers <dict> and postData <dict> | <str>
  • url <str> url of the response.

CAUTION: Before Browser library 17.0.0, the matcher argument was always either a regex or JS function. But the regex did not need to be in slashes. The most simple way to migrate to the new syntax is to add slashes around the matcher. So /api/get/json becomes //api/get/json/.

Glob-Patterns are strings that can contain wildcards. Possible wildcards/patterns are:

  • * matches any number of characters, except /
  • ** matches any number of characters, including /
  • ? matches one character, except /
  • [abc] matches one character in the brackets (in this example a, b or c)
  • [a-z] matches one character in the range (in this example a to z)
  • {foo,bar,baz} matches one of the strings in the braces (in this example foo, bar or baz)

Example:

`Wait For Response` **/api/get/text # matches any response with url ending with /api/get/text. example: https://browser.fi/api/get/text

Regular Expressions are JavaScript regular expressions enclosed in / with optional trailing flags. Be aware that backslashes need to be escaped in Robot Framework, e.g. \\w instead of \w. See regex101 for more information on Regular Expressions.

Example:

`Wait For Response` /http://\\w+:\\d+/api/get/text/i # matches any response with url ending with /api/get/text and containing http:// followed by any word and port. example: http://localhost:8080/api/get/text

JavaScript Arrow-Functions are anonymous JavaScript functions that receive the Response object and return a boolean.

Example:

`Wait For Response` response => response.url() === 'http://localhost/api/post' && response.status() === 200 # matches any response with url http://localhost/api/post and status code 200

Synchronous Example:

`Click` \#delayed_request # Creates response which should be waited before next actions
`Wait For Response` matcher=/http://\\w+:\\d+/api/get/text/i
`Click` \#save

Asynchronous Example:

${promise} = `Promise To` `Wait For Response` timeout=60s
`Click` \#delayed_request # Creates response which should be waited before pressing save.
`Click` \#next
`Wait For` ${promise} # Waits for the response
`Click` \#save

JavaScript Function Example:

`Click` \#delayed_request # Creates response which should be waited before pressing save.
`Wait For Response` response => response.url().endsWith('json') && response.request().method() === 'GET'

Comment >>


Any value is accepted. No conversion is done.

  • Any

Enumeration that defines which coordinates of an area should be selected.

ALL defines that all fields are selected and a dictionary with all information is returned.

  • top
  • left
  • bottom
  • right
  • ALL
  • string

Defines the mode of the AriaSnapshot.

Value Description
default Standard aria snapshot.
ai Snapshot optimized for AI consumption. It includes element references like [ref=e2], includes snapshots of iframes inside the target and does not wait for a matching element, but fails immediately when no element matches.
  • default
  • ai
  • string

Defines the return type of the AriaSnapshot.

Value Description
dict returns the snapshot as a dictionary.
yaml returns the snapshot as a yaml string.
parsed returns the snapshot as a tree of node dictionaries.

dict loads the yaml as it is. Role, name and all annotations of an element stay inside the dictionary keys, for example {'heading "Login Page" [level=1]': None}.

parsed splits that information into separate keys. Every node has role, name, text, props and children, and its values are reachable both as ${node}[role] and as ${node.role}. Annotations without a value, like [selected], become True, [level=2] becomes an integer and box uses the same keys as Get BoundingBox. The /url entry of a link is an annotation in Playwright, not an element, and therefore becomes the url property of the link instead of one of its children.

All outputs below come from the same element of the same page. It offers fourteen tag options; the examples stop after the fourth one:

`New Browser` chromium
`New Page` https://robotframework-browser.org/keywords
${snapshot} = `Get Aria Snapshot` .rail-top
- text: Filter keywords
- searchbox "Filter keywords"
- group: Version 20.3.0
- text: Filter by tag
- combobox "Filter by tag":
- option "— Show all tags —" [selected]
- option "Setter (84)"
- option "PageContent (83)"
- option "Getter (45)"
- text: Filter keywords
- searchbox "Filter keywords" [box=12,77,279,30]
- group [box=12,116,279,34]: Version 20.3.0
- text: Filter by tag
- combobox "Filter by tag" [box=12,158,279,32]:
- option "— Show all tags —" [selected] [box=0,0,0,0]
- option "Setter (84)" [box=0,0,0,0]
- option "PageContent (83)" [box=0,0,0,0]
- option "Getter (45)" [box=0,0,0,0]
return_type=yaml with boxes=True and mode=ai
Section titled “return_type=yaml with boxes=True and mode=ai”
- generic [ref=f2e1] [box=0,65,303,137]:
- generic [ref=f2e3] [box=12,77,279,30]:
- generic [ref=f2e4] [box=12,77,1,1]: Filter keywords
- searchbox "Filter keywords" [ref=f2e5] [box=12,77,279,30]
- generic [ref=f2e6] [box=12,116,279,74]:
- group [ref=f2e7] [box=12,116,279,34]:
- generic "Version 20.3.0" [ref=f2e8] [cursor=pointer] [box=12,116,157,34]:
- generic [ref=f2e9] [box=22,124,66,18]: Version
- generic [ref=f2e10] [box=96,121,49,22]: 20.3.0
- generic [ref=f2e12] [box=12,158,279,32]:
- generic [ref=f2e13] [box=12,158,1,1]: Filter by tag
- combobox "Filter by tag" [ref=f2e14] [box=12,158,279,32]:
- option "— Show all tags —" [selected] [box=0,0,0,0]
- option "Setter (84)" [box=0,0,0,0]
- option "PageContent (83)" [box=0,0,0,0]
- option "Getter (45)" [box=0,0,0,0]
[
{
'text': 'Filter keywords'
},
'searchbox "Filter keywords" [box=12,77,279,30]',
{
'group [box=12,116,279,34]': 'Version 20.3.0'
},
{
'text': 'Filter by tag'
},
{
'combobox "Filter by tag" [box=12,158,279,32]': [
'option "— Show all tags —" [selected] [box=0,0,0,0]',
'option "Setter (84)" [box=0,0,0,0]',
'option "PageContent (83)" [box=0,0,0,0]'
'option "Getter (45)" [box=0,0,0,0]'
]
}
]

Fully parsed snapshot as Robot Framework dictionary:

[
{
'role': 'text',
'name': None,
'text': 'Filter keywords',
'props': {},
'children': []
},
{
'role': 'searchbox',
'name': 'Filter keywords',
'text': None,
'props': {
'box': {
'x': 12,
'y': 77,
'width': 279,
'height': 30
}
},
'children': []
},
{
'role': 'group',
'name': None,
'text': 'Version 20.3.0',
'props': {
'box': {
'x': 12,
'y': 116,
'width': 279,
'height': 34
}
},
'children': []
},
{
'role': 'text',
'name': None,
'text': 'Filter by tag',
'props': {},
'children': []
},
{
'role': 'combobox',
'name': 'Filter by tag',
'text': None,
'props': {
'box': {
'x': 12,
'y': 158,
'width': 279,
'height': 32
}
},
'children': [
{
'role': 'option',
'name': '— Show all tags —',
'text': None,
'props': {
'selected': True,
'box': {
'x': 0,
'y': 0,
'width': 0,
'height': 0
}
},
'children': []
},
{
'role': 'option',
'name': 'Setter (84)',
'text': None,
'props': {
'box': {
'x': 0,
'y': 0,
'width': 0,
'height': 0
}
},
'children': []
},
{
'role': 'option',
'name': 'PageContent (83)',
'text': None,
'props': {
'box': {
'x': 0,
'y': 0,
'width': 0,
'height': 0
}
},
'children': []
},
{
'role': 'option',
'name': 'Getter (45)',
'text': None,
'props': {
'box': {
'x': 0,
'y': 0,
'width': 0,
'height': 0
}
},
'children': []
}
]
}
]
  • dict
  • yaml
  • parsed
  • string

Currently supported assertion operators are:

Operator Alternative Operators Description Validate Equivalent
== equal, equals, should be Checks if returned value is equal to expected value. value == expected
!= inequal, should not be Checks if returned value is not equal to expected value. value != expected
> greater than Checks if returned value is greater than expected value. value > expected
>= Checks if returned value is greater than or equal to expected value. value >= expected
\< less than Checks if returned value is less than expected value. value \< expected
\<= Checks if returned value is less than or equal to expected value. value \<= expected
*= contains Checks if returned value contains expected value as substring. expected in value
not contains Checks if returned value does not contain expected value as substring. expected in value
^= should start with, starts Checks if returned value starts with expected value. re.search(f"^{expected}", value)
$= should end with, ends Checks if returned value ends with expected value. re.search(f"{expected}$", value)
matches Checks if given RegEx matches minimum once in returned value. re.search(expected, value)
validate Checks if given Python expression evaluates to True.
evaluate then When using this operator, the keyword does return the evaluated Python expression.

There are three different possibilities what keyword returns when matches operator is used: string, tuple or dictionary. What keyword returns depends on how the RegEx is formed. If RegEx does not contain group(s), then keyword will return the string without modifications. If RegEx contains groups, meaning (…), then keyword will return a tuple. Each tuple item contains the text which is matched by the group. If there is group and group has a name, (?P<name>…) syntax, then keyword returns a dictionary. In this case dictionary key is the group name and value contains the matched text. If there mix of groups and groups with names, then tuple is returned.

Currently supported formatters for assertions are:

Formatter Description
normalize spaces Substitutes multiple spaces to single space from the value
strip Removes spaces from the beginning and end of the value
case insensitive Converts value to lower case before comparing
apply to expected Applies rules also for the expected value

Formatters are applied to the value before assertion is performed and keywords returns a value where rule is applied. Formatter is only applied to the value which keyword returns and not all rules are valid for all assertion operators. If apply to expected formatter is defined, then formatters are then formatter are also applied to expected value.

  • equal
  • equals
  • ==
  • should be
  • inequal
  • !=
  • should not be
  • less than
  • <
  • greater than
  • >
  • <=
  • >=
  • contains
  • not contains
  • *=
  • starts
  • ^=
  • should start with
  • ends
  • should end with
  • $=
  • matches
  • validate
  • then
  • evaluate
  • string

Controls when contexts and pages are closed during the test execution.

If automatic closing level is TEST, contexts and pages that are created during a single test are automatically closed when the test ends. Contexts and pages that are created during suite setup are closed when the suite teardown ends.

If automatic closing level is SUITE, all contexts and pages that are created during the test suite are closed when the suite teardown ends.

If automatic closing level is MANUAL, nothing is closed automatically while the test execution is ongoing. All browsers, context and pages are automatically closed when test execution ends.

If automatic closing level is KEEP, nothing is closed automatically while the test execution is ongoing. Also, nothing is closed when test execution ends, including the node process. Therefore, it is users responsibility to close all browsers, context and pages and ensure that all process that are left running after the test execution end are closed. This level is only intended for test case development and must not be used when running tests in CI or similar environments.

Automatic closing can be configured or switched off with the auto_closing_level library import parameter.

See: Importing

  • SUITE
  • TEST
  • MANUAL
  • KEEP
  • string

Strings TRUE, YES, ON, 1 and possible localization specific “true strings” are converted to Boolean True, the empty string, strings FALSE, NO, OFF and 0 and possibly localization specific “false strings” are converted to Boolean False, and the string NONE is converted to the Python None object. Other strings and all other values are passed as-is, allowing keywords to handle them specially if needed. All string comparisons are case-insensitive.

Examples: TRUE (converted to True), off (converted to False), example (used as-is)

  • string
  • integer
  • float
  • None

Bounding box of an element.

Key Description
x The amount of pixel between the left border of the page and the left border of the element.
y The amount of pixel between the top border of the page and the top border of the element.
width The width of the element, excluding margins.
height The height of the element, excluding margins.
{'x': <float> # optional
'y': <float> # optional
'width': <float> # optional
'height': <float> # optional
}
  • string
  • Mapping

Enumeration that defines which location information of an element should be selected.

x / y defines the position of the top left corner of an element.

width / height defines the size of an elements bounding box.

ALL defines that all fields are selected and a dictionary with all information is returned.

  • width
  • height
  • x
  • y
  • ALL
  • string

Strings are converted to bytes so that each Unicode code point below 256 is directly mapped to a matching byte. Higher code points are not allowed. Robot Framework’s \xHH escape syntax is convenient with bytes having non-printable values.

Examples: good, hyvä (same as hyv\xE4), \x00 (the null byte)

Integers and sequences of integers are converted to matching bytes directly. They must be in range 0-255.

Examples: 0 (converted to the null byte), [82, 70] (converted to RF)

Support for integers and sequences of integers is new in Robot Framework 7.4.

  • string
  • bytearray
  • Sequence
  • integer

Returned client credential.

  • id Base64url-encoded credential id.
  • rpId Relying party id (typically the site’s effective domain).
  • userHandle Base64url-encoded user handle.
  • privateKey Base64url-encoded PKCS#8 (DER) private key.
  • publicKey Base64url-encoded SPKI (DER) public key.

Example usage: {'id': 'localhost', 'rpId': 'localhost', 'userHandle': 'localhost', 'privateKey': 'localhost', 'publicKey': 'localhost'}

{'id': <str>
'rpId': <str>
'userHandle': <str>
'privateKey': <Secret>
'publicKey': <Secret>
}
  • string
  • Mapping

Defines how time is advanced.

fast_forward: Advance the clock by jumping forward in time. run_for: Advance the clock, firing all the time-related callbacks.

fast_forward will Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it later, after given time.

  • fast_forward
  • run_for
  • string

Defines how time is set.

The recommended approach is to use fixed to set the time to a specific value.

fixed: Sets the fixed time for Date.now() and new Date(). system: Is only recommended for advanced use cases. install: initializes the clock and allows you to: pause_at: Pauses the time at a specific time. fast_forward: Fast forwards the time. run_for: Runs the time for a specific duration. resume: Resumes the time.

  • fixed
  • system
  • install
  • string

Emulates ‘prefers-color-scheme’ media feature. Supported values are ‘light’, ‘dark’, ‘no-preference’ and null. Passing null disables color scheme emulation. no-preference is deprecated.

See emulateMedia(options) for more details.

  • dark
  • light
  • no-preference
  • null
  • string

Following values are allowed and represent the assertion keywords to use:

Value Keyword
Attribute Get Attribute
Attribute Names Get Attribute Names
BoundingBox Get BoundingBox
Browser Catalog Get Browser Catalog
Checkbox State Get Checkbox State
Classes Get Classes
Client Size Get Client Size
Download State Get Download State
Element Count Get Element Count
Element States Get Element States
Page Source Get Page Source
Property Get Property
Scroll Position Get Scroll Position
Scroll Size Get Scroll Size
Select Options Get Select Options
Selected Options Get Selected Options
Style Get Style
Table Cell Index Get Table Cell Index
Table Row Index Get Table Row Index
Text Get Text
Title Get Title
Url Get Url
Viewport Size Get Viewport Size
  • attribute
  • attribute_names
  • bounding_box
  • browser_catalog
  • checkbox_state
  • classes
  • client_size
  • download_state
  • element_count
  • element_states
  • page_source
  • property
  • scroll_position
  • scroll_size
  • select_options
  • selected_options
  • style
  • table_cell_index
  • table_row_index
  • text
  • title
  • url
  • viewport_size
  • string

Enum that defines the Cookie SameSite type.

It controls whether or not a cookie is sent with cross-site requests, providing some protection against cross-site request forgery attacks (CSRF).

The possible attribute values are:

Value Description
Strict Means that the browser sends the cookie only for same-site requests, that is, requests originating from the same site that set the cookie. If a request originates from a different domain or scheme (even with the same domain), no cookies with the SameSite=Strict attribute are sent.
Lax Means that the cookie is not sent on cross-site requests, such as on requests to load images or frames, but is sent when a user is navigating to the origin site from an external site (for example, when following a link). This is the default behavior if the SameSite attribute is not specified.
None means that the browser sends the cookie with both cross-site and same-site requests. The Secure attribute must also be set when setting this value.

See MDN Set-Cookie for more information.

  • Strict
  • Lax
  • None
  • string

Enum that defines the Cookie type.

  • dictionary
  • dict
  • string
  • str
  • string

Enum that defines the type of coverage to collect.

js: JavaScript coverage. css: CSS coverage. all: Both CSS and JS coverage.

  • js
  • css
  • all
  • string

String timestamps are expected to be in ISO 8601 like format YYYY-MM-DD hh:mm:ss.mmmmmm, where any non-digit character can be used as a separator or separators can be omitted altogether. Additionally, only the date part is mandatory, all possibly missing time components are considered to be zeros.

A special values NOW and TODAY (case-insensitive) can be used to get the current local datetime. This is new in Robot Framework 7.3.

Integers and floats are considered to represent seconds since the Unix epoch.

Examples: 2022-02-09T16:39:43.632269, 20220209 16:39, now, ${1644417583.632269} (Epoch time)

  • string
  • integer
  • float

Enum that defines how to handle a dialog.

  • accept
  • dismiss
  • string

Strings must be Python dictionary literals. They are converted to actual dictionaries using the ast.literal_eval function. They can contain any values ast.literal_eval supports, including dictionaries and other collections.

Any mapping is accepted and converted to a dict.

If the type has nested types like dict[str, int], items are converted to those types automatically. This in new in Robot Framework 6.0.

Examples: {'a': 1, 'b': 2}, {'key': 1, 'nested': {'key': 2}}

  • string
  • Mapping

Dimensions of an object in pixels.

{'width': <int>
'height': <int>
}
  • string
  • Mapping

Downloaded file information.

Key Description
saveAs is the path where downloaded file is saved. empty string if the file is not yet fully downloaded.
suggestedFilename is the suggested filename that was computed from the Content-Disposition response header.
state is the state of the download. i.e. in_progress, finished or canceled.
downloadID is the unique id of the download.
{'saveAs': <str>
'suggestedFilename': <str>
'state': <str>
'downloadID': <str | None>
}
  • string
  • Mapping

Role selector does not replace accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.

Many html elements have an implicitly defined role that is recognized by the role selector. You can find all the supported roles here. ARIA guidelines do not recommend duplicating implicit roles and attributes by setting role and/or aria-* attributes to default values.

  • ALERT
  • ALERTDIALOG
  • APPLICATION
  • ARTICLE
  • BANNER
  • BLOCKQUOTE
  • BUTTON
  • CAPTION
  • CELL
  • CHECKBOX
  • CODE
  • COLUMNHEADER
  • COMBOBOX
  • COMPLEMENTARY
  • CONTENTINFO
  • DEFINITION
  • DELETION
  • DIALOG
  • DIRECTORY
  • DOCUMENT
  • EMPHASIS
  • FEED
  • FIGURE
  • FORM
  • GENERIC
  • GRID
  • GRIDCELL
  • GROUP
  • HEADING
  • IMG
  • INSERTION
  • LINK
  • LIST
  • LISTBOX
  • LISTITEM
  • LOG
  • MAIN
  • MARQUEE
  • MATH
  • METER
  • MENU
  • MENUBAR
  • MENUITEM
  • MENUITEMCHECKBOX
  • MENUITEMRADIO
  • NAVIGATION
  • NONE
  • NOTE
  • OPTION
  • PARAGRAPH
  • PRESENTATION
  • PROGRESSBAR
  • RADIO
  • RADIOGROUP
  • REGION
  • ROW
  • ROWGROUP
  • ROWHEADER
  • SCROLLBAR
  • SEARCH
  • SEARCHBOX
  • SEPARATOR
  • SLIDER
  • SPINBUTTON
  • STATUS
  • STRONG
  • SUBSCRIPT
  • SUPERSCRIPT
  • SWITCH
  • TAB
  • TABLE
  • TABLIST
  • TABPANEL
  • TERM
  • TEXTBOX
  • TIME
  • TIMER
  • TOOLBAR
  • TOOLTIP
  • TREE
  • TREEGRID
  • TREEITEM
  • string

Enum that defines the state an element can have.

The following states are possible:

State Description
attached to be present in DOM.
detached to not be present in DOM.
visible to have non or empty bounding box and no visibility:hidden.
hidden to be detached from DOM, or have an empty bounding box or visibility:hidden.
enabled to not be disabled.
disabled to be disabled. Can be used on <button>, <fieldset>, <input>, <optgroup>, <option>, <select> and <textarea>.
editable to not be readOnly.
readonly to be readOnly. Can be used on <input> and <textarea>.
selected to be selected. Can be used on <option>.
deselected to not be selected.
focused to be the activeElement.
defocused to not be the activeElement.
checked to be checked. Can be used on <input>.
unchecked to not be checked.
stable to be both visible and stable.
  • attached
  • detached
  • visible
  • hidden
  • enabled
  • disabled
  • editable
  • readonly
  • selected
  • deselected
  • focused
  • defocused
  • checked
  • unchecked
  • stable
  • string
  • integer

Dictionary that contains information about a file upload buffer.

Key Description
name The name of the file.
mimeType The mime type of the file.
buffer The file content.

Structure:

{
'name': ``str``,
'mimeType': ``str``,
'buffer': ``str``
}
{'name': <str>
'mimeType': <str>
'buffer': <str>
}
  • string
  • Mapping

Conversion is done using Python’s float built-in function.

Spaces and underscores can be used as visual separators for digit grouping purposes.

Examples: 3.14, 2.9979e8, 10 000.000 01

  • string
  • Real

Emulates ‘forced-colors’ media feature.

Supported values are ‘active’, ‘none’ and null. Passing null disables forced colors emulation.

  • active
  • none
  • null
  • string

Enum that defines the available formatters.

Formatter Description
normalize spaces Replaces all kind of spaces with a single space.
strip Removes spaces from start and end of the string.
apply to expected Applies the formatter also to the expected value.
case insensitive Converts the string to lower case.
  • normalize spaces
  • strip
  • apply to expected
  • case insensitive
  • string

Enum that defines the available keywords for formatters.

Keywords that are not listed here, do not support formatters.

  • Get Attribute
  • Get Browser Catalog
  • Get Page Source
  • Get Property
  • Get Select Options
  • Get Style
  • Get Text
  • Get Title
  • Get Url
  • LocalStorage Get Item
  • SessionStorage Get Item
  • string

Presenter mode configuration options.

duration Sets for how long the selector shall be highlighted. Defaults to 5s => 5 seconds.

width Sets the width of the higlight border. Defaults to 2px.

style Sets the style of the border. Defaults to dotted.

color Sets the color of the border, default is blue. Valid colors i.e. are: red, blue, yellow, pink, black

{'duration': <timedelta> # optional
'width': <str> # optional
'style': <str> # optional
'color': <str> # optional
}
  • string
  • Mapping

Highlight mode for the element.

border: Highlights the element with a border outside of the selected element. This is the classic way to highlight an element of Browser librarary.

playwright: Highlights the element with Playwrights built in function.

both: Highlights the element with both methods.

  • border
  • playwright
  • both
  • string

Conversion is done using Python’s int built-in function. Floating point numbers are accepted only if they can be represented as integers exactly. For example, 1.0 is accepted and 1.1 is not.

It is possible to use hexadecimal, octal and binary numbers by prefixing values with 0x, 0o and 0b, respectively. Spaces and underscores can be used as visual separators for digit grouping purposes.

Examples: 42, -1, 0b1010, 10 000 000, 0xBAD_C0FFEE

  • string
  • float

Enum that defines which Keyboard Key action to perform.

  • down
  • up
  • press
  • string

Enum that defines how Keyboard Input adds the text into the page.

insertText is mostly similar to pasting of text.

type is similar to typing by pressing keys on the keyboard.

  • insertText
  • type
  • string

Modifier keys to press while doing other actions.

Modifiers that are pressed during the Hover or Click.

  • Alt
  • Control
  • ControlOrMeta
  • Meta
  • Shift
  • string

Python lambda function.

The string must start with lambda and the function must accept one argument.

Example: lambda value: value.lower().replace(' ', '')

  • string

Strings must be Python list or tuple literals. They are converted using the ast.literal_eval function and possible tuples converted further to lists. They can contain any values ast.literal_eval supports, including lists and other collections.

If the argument is a list, it is used without conversion. Tuples and other sequences are converted to lists.

If the type has nested types like list[int], items are converted to those types automatically.

Examples: ['one', 'two'], [('one', 1), ('two', 2)]

Support to convert nested types is new in Robot Framework 6.0. Support for tuple literals is new in Robot Framework 7.4.

  • string
  • Sequence

Strings must be Python dictionary literals. They are converted to actual dictionaries using the ast.literal_eval function. They can contain any values ast.literal_eval supports, including dictionaries and other collections.

Any mapping is accepted without conversion. An exception is that if the type is MutableMapping, immutable values are converted to dict.

If the type has nested types like Mapping[str, int], items are converted to those types automatically. This in new in Robot Framework 6.0.

Examples: {'a': 1, 'b': 2}, {'key': 1, 'nested': {'key': 2}}

  • string
  • Mapping

Changes the CSS media type of the page.

The only allowed values are ‘screen’, ‘print’ and null. Passing null disables CSS media emulation. Using False will not define media argument.

  • screen
  • print
  • null
  • string

Enum that defines which mouse button to use.

  • left
  • middle
  • right
  • string

Enum that defines which Mouse Button action to perform.

  • click
  • down
  • up
  • string

Return value of New Page keyword.

page_id is the UUID of the opened page. video_path path to the video or empty string if video is not created.

{'page_id': <str>
'video_path': <str>
}
  • string
  • Mapping

String NONE (case-insensitive) and the empty string are converted to the Python None object. Other values cause an error.

Converting the empty string is new in Robot Framework 7.4.

  • string

Defines a value that is not set.

This is used to differentiate between a value that is set to None and a value that is not set at all. Example ForcedColors has an options active, none and null. If user does not not want to give any of the ForcedColors options, user can use not_set value. Then keyword will not define ForcedColors option at all when underlying Playwright method(s) is called.

  • not_set
  • string

Enum that defines available page load states.

  • load
  • domcontentloaded
  • networkidle
  • commit
  • string

Strings are converted Path objects. On Windows / is converted to \ automatically.

Examples: /tmp/absolute/path, relative/path/to/file.ext, name.txt

  • string
  • PurePath

Enum that defines the permission to grant to a context.

See grantPermissions(permissions) for more details.

  • accelerometer
  • accessibility-events
  • accessibility_events
  • ambient-light-sensor
  • ambient_light_sensor
  • background-sync
  • background_sync
  • camera
  • clipboard-read
  • clipboard_read
  • clipboard-write
  • clipboard_write
  • geolocation
  • gyroscope
  • local-network-access
  • local_network_access
  • magnetometer
  • midi
  • midi-sysex
  • midi_sysex
  • microphone
  • notifications
  • payment-handler
  • payment_handler
  • string

Enable low level debug information from the playwright to playwright-log.txt file.

It is possible to disable the creation of playwright-log.txt totally. Mainly useful for the library developers and for debugging purposes. Will log everything as plain text, also including secrets. If playwright-log.txt file can not be deleted, time.time_ns() is added at the end of file name. Example playwright-log-12345.txt

disabled: playwright-log.txt is not created at all. All node side logging is lost. library: Default, only logging from Browser library node side is written to the playwright-log.txt file. playwright: Also includes Playwright log messages to the playwright-log.txt file. false: Same as library and for backwards compatability. true: Same as playwright and for backwards compatibility.

  • disabled
  • library
  • playwright
  • false
  • true
  • string

Enables HAR recording for all pages into to a file.

If not specified, the HAR is not recorded. Make sure to await context to close for the HAR to be saved.

omitContent: Optional setting to control whether to omit request content from the HAR. Default is False

path: Path on the filesystem to write the HAR file to. A relative path is relative to the output directory.

Example:

${har} = Create Dictionary path=/path/to/har.file omitContent=True
New Context recordHar=${har}
{'omitContent': <bool> # optional
'path': <str> # optional
}
  • string
  • Mapping

Enables Video recording

Key Description
dir Folder of the videos.
size ViewportDimensions of the videos.
fps Frame rate of the videos. Defaults to 25. Firefox and WebKit record at most 25 frames per second.
showActions Annotates the interacted elements in the videos, with the keys below.

Keys of showActions:

Key Description
duration How long each annotation is shown, in milliseconds. Defaults to 500.
position Position of the action title: top-left, top, top-right (default), bottom-left, bottom or bottom-right.
cursor pointer (default) shows a mouse pointer that moves from one action point to the next, none shows no cursor.
style CSS declarations of the annotations: point for the marker on the action point and highlight for the box over the element, both shown only when given, and title for the action title.

Examples:

New Context recordVideo={'dir':'videos', 'size':{'width':400, 'height':200}}
New Context recordVideo={'dir': 'd:/automation/video'}
New Context recordVideo={'showActions': {'position': 'bottom', 'style': {'title': 'font-size: 32px'}}}
{'dir': <str> # optional
'size': <ViewportDimensions> # optional
'fps': <int> # optional
'showActions': <ShowActions> # optional
}
  • string
  • Mapping

Emulates ‘prefers-reduced-motion’ media feature.

Supported values are ‘reduce’, ‘no-preference’ and null. Passing null disables reduced motion emulation.

  • reduce
  • no_preference
  • null
  • string

Create a (JavaScript) RegExp object from a string.

The matcher must start with a slash and end with a slash and can be followed by flags.

Example: /hello world/gi Which is equivalent to new RegExp("hello world", "gi") in JavaScript.

Following flags are supported:

Flag Description
g Global search.
i Case-insensitive search.
m Allows ^ and $ to match newline characters.
s Allows . to match newline characters.
u “unicode”; treat a pattern as a sequence of unicode code points.
y Perform a “sticky” search that matches starting at the current position in the target string.

See RegExp Object and RegExp Guide for more information.

  • string

Enum that defines the request type.

  • HEAD
  • DELETE
  • GET
  • PATCH
  • POST
  • PUT
  • string

Enum that defines the scale of the screenshot.

When set to “css”, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using “device” option will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.

  • css
  • device
  • string

Some keywords which manipulates library settings have a scope argument. With that scope argument one can set the “live time” of that setting. Available Scopes are: Global, Suite and Test / Task. Is a scope finished, this scoped setting, like timeout, will no longer be used and the previous higher scope setting applies again.

Live Times:

  • A Global scope will live forever until it is overwritten by another Global scope. Or locally temporarily overridden by a more narrow scope.
  • A Suite scope will locally override the Global scope and live until the end of the Suite within it is set, or if it is overwritten by a later setting with Global or same scope. Children suite does inherit the setting from the parent suite but also may have its own local Suite setting that then will be inherited to its children suites.
  • A Test or Task scope will be inherited from its parent suite but when set, lives until the end of that particular test or task.

A new set higher order scope will always remove the lower order scope which may be in charge. So the setting of a Suite scope from a test, will set that scope to the robot file suite where that test is and removes the Test scope that may have been in place.

  • Global
  • Suite
  • Test
  • Task
  • string

Enum that defines available file types for screenshots.

  • png
  • jpeg
  • string

Enum that defines what Take Screenshot keyword returns.

  • path returns the path to the screenshot file as pathlib.Path object.
  • path_string returns the path to the screenshot file as string.
  • bytes returns the screenshot itself as bytes.
  • base64 returns the screenshot itself as base64 encoded string.
  • path
  • path_string
  • bytes
  • base64
  • string

Enum that controls the behavior of scrolling.

smooth

  • auto
  • smooth
  • string

Scroll position of an element.

Key Description
top The amount of pixel between the top border of the page and the top border of visible area.
left The amount of pixel between the left border of the page and the left border of visible area.
bottom The amount of pixel between the top border of the page and the bottom border of visible area.
right The amount of pixel between the left border of the page and the right border of visible area.
{'top': <float>
'left': <float>
'bottom': <float>
'right': <float>
}
  • string
  • Mapping

Encapsulates secret values to avoid them being shown in Robot Framework logs.

The value is required to be robot.api.types.Secret object. These objects encapsulate confidential values so that they are not exposed in log files. How to create them is explained in the User Guide.

New in Robot Framework 7.4.

  • string

Enum that defines the attribute of an <option> element in a <select>-list.

This defines by what attribute an option is selected/chosen.

<select class="my_drop_down">
<option value="0: Object">None</option>
<option value="1: Object">Some</option>
<option value="2: Object">Other</option>
</select>

value of the first option would be 0: Object.

label / text both defines the innerText which would be None for first element.

index 0 indexed number of an option. Would be 0 for the first element.

  • value
  • label
  • text
  • index
  • string

SelectionStrategy to be used. Refers to Playwrights page.getBy*** functions. See Playwright Locators

All images should have an alt attribute that describes the image. You can locate an image based on the text alternative using page.getByAltText().

For example, consider the following DOM structure.

<img alt="playwright logo" src="/img/playwright-logo.svg" width="100" />

Allows locating input elements by the text of the associated \<label> or aria-labelledby element, or by the aria-label attribute.

For example, this method will find inputs by label “Username” and “Password” in the following DOM:

<input aria-label="Username">
<label for="password-input">Password:</label>
<input id="password-input">

Allows locating input elements by the placeholder text.

Example:

<input type="email" placeholder="name@example.com" />

Locate element by the test id.

Currently only the exact attribute data-testid is supported.

Example:

<button data-testid="directions">Itinéraire</button>

Allows locating elements that contain given text.

Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace. Input elements of the type button and submit are matched by their value instead of the text content. For example, locating by text “Log in” matches <input type=button value=“Log in”>.

Allows locating elements by their title attribute.

Example:

<img alt="playwright logo" src="/img/playwright-logo.svg" title="Playwright" width="100" />
  • AltText
  • Label
  • Placeholder
  • TestID
  • Text
  • Title
  • string

Enum that defines if the current id or all ids shall be returned.

ACTIVE / CURRENT defines to return only the id of the currently active instance of a Browser/Context/Page.

ALL / ANY defines to return ids of all instances.

  • CURRENT
  • ACTIVE
  • ALL
  • ANY
  • string

Dictionary with the following keys and their values “index”, “value”, “label” and “selected”.

Keys Description
index 0 based index of the option.
value Value attribute of the option.
label Label/Text of the option.
selected Boolean if the option is selected.
{'index': <int>
'value': <str>
'label': <str>
'selected': <bool>
}
  • string
  • Mapping

How Record Selector writes the selector of the picked element.

playwright: Playwright’s own selector, the one its codegen and Record Keyword use: role, text, label, placeholder or test id where they identify the element, written in Browser selector syntax, for example role=button[name="Save"s].

css: A CSS selector built from ids, classes, attributes and the element’s position, for example \#login > div.form > button:nth-child(2). Frames are joined with >>> and open shadow roots with >>.

  • playwright
  • css
  • string

Enum that defines how the returned size is filtered.

ALL defines that the size is returned as a dictionary. {'width': \<float>, 'height': \<float>}.

width / height will return a single float value of the chosen dimension.

  • width
  • height
  • ALL
  • string

All arguments are converted to Unicode strings.

Most values are converted simply by using str(value). An exception is that bytes are mapped directly to Unicode code points with same ordinals. This means that, for example, b"hyv\xe4" becomes "hyvä".

Converting bytes specially is new Robot Framework 7.4.

  • Any

Defines which browser shall be started.

Browser Browser with this engine
chromium Google Chrome, Microsoft Edge (since 2020), Opera
firefox Mozilla Firefox
webkit Apple Safari, Mail, AppStore on MacOS and iOS

Since Playwright comes with a pack of builtin binaries for all browsers, no additional drivers e.g. geckodriver are needed.

All these browsers that cover more than 85% of the world wide used browsers, can be tested on Windows, Linux and MacOS. Theres is not need for dedicated machines anymore.

  • chromium
  • firefox
  • webkit
  • string

Defines which Playwright method is used to get the text of an element.

allInnerTexts: Returns a list of node.innerText values for all matching nodes.

allTextContents: Returns a list of node.textContent values for all matching nodes.

innerText: Returns the element node.innerText value, which represents the rendered text content of a node and its descendants.

inputValue: Returns the value for the matching <input> or <textarea> or <select> element.

innerHTML: Returns the element node.innerHTML value, which is the HTML markup contained within the element, omitting any shadow roots.

  • allInnerTexts
  • allTextContents
  • innerText
  • inputValue
  • innerHTML
  • string

Strings are expected to represent a time interval in one of the time formats Robot Framework supports:

  • a number representing seconds like 42 or 10.5
  • a time string like 1 hour 2 seconds or 1h 2s
  • a “timer” string like 01:02 (1 minute 2 seconds) or 01:00:03 (1 hour 3 seconds)

Integers and floats are considered to be seconds.

See the Robot Framework User Guide for more details about the supported time formats.

  • string
  • integer
  • float

Defines in what detail level keywords are written to Playwright trace.

Playwrright trace is a full log of all playwright actions and events that happen in the browser during the test run. This includes all API calls, events, logs, network requests, and responses as well as the DOM at every moment during execution. This trace can be activated with the tracing parameter of New Context keyword.

  • Full All keyword calls are written to trace as groups even if they do not call Browser keywords.
  • Browser Just Browser library keywords are written to the logs as groups.
  • Playwright No additional keywords are logged, just the Playwright API calls.
  • Full
  • Browser
  • Playwright
  • string

Strings must be Python tuple or list literals. They are converted using the ast.literal_eval function and possible lists converted further to tuples. They can contain any values ast.literal_eval supports, including tuples and other collections.

If the argument is a tuple, it is used without conversion. Lists and other sequences are converted to tuples.

If the type has nested types like tuple[str, int, int], items are converted to those types automatically.

Examples: ('one', 'two'), (('one', 1), ('two', 2))

Support to convert nested types is new in Robot Framework 6.0. Support for list literals is new in Robot Framework 7.4.

  • string
  • Sequence

Viewport dimensions.

Viewport is the browsers inner window size that is used to display the page.

Key Description
width page width in pixels.
height page height in pixels.
{'width': <int>
'height': <int>
}
  • string
  • Mapping