Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

RPA.Browser.Playwright

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

Arguments

ArgumentTypeDefault value
contentstrnull
ArgumentsDescription
contentRaw CSS content to be injected into frame.

Usage

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

Checks the checkbox or selects radio button found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
forceboolFalse
ArgumentsDescription
selectorSelector of the checkbox. See the Finding elements section for details about the selectors.
forceSet to True to skip Playwright's [https://playwright.dev/docs/actionabilityActionability checks].

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

Does nothing if the element is already checked/selected.

Clears all permissions from the current context.

Clears the text field found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
ArgumentsDescription
selectorSelector of the text field. See the Finding elements section for details about the selectors.

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

See Type Text for emulating typing text character by character. See Fill Text for direct filling of the full text at once.

Simulates mouse click on the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
buttonMouseButtonleft
clickCountDeprecated
delayDeprecated
position_xDeprecated
position_yDeprecated
forceDeprecated
noWaitAfterDeprecated
modifiersDeprecatednull

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

  • Find an element matches selector. If there is none, wait until a matching element is attached to the DOM.
  • Wait for actionability checks on the matched element, unless 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 noWaitAfter option is set.
ArgumentsDescription
selectorSelector element to click. See the Finding elements section for details about the selectors.
buttonDefaults to left if invalid.

! The arguments marked as Deprecated will be removed in the future, but the Click keyword will still be available! The reason for removing these arguments is the bad design of modifiers, which forces the user to set all other arguments as positional arguments when modifiers are used, and the missing extensibility of the keyword. Please use Click With Options when using arguments that are marked as deprecated.

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

Usage

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

Simulates mouse click on the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
buttonMouseButtonleft
modifiersKeyboardModifiernull
clickCountint1
delaytimedelta, NoneNone
forceboolFalse
noWaitAfterboolFalse
position_xfloat, NoneNone
position_yfloat, NoneNone
trialboolFalse

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

  • Find an element matches selector. If there is none, wait until a matching element is attached to the DOM.
  • Wait for actionability checks on the matched element, unless 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 noWaitAfter option is set.
ArgumentsDescription
selectorSelector element to click. See the Finding elements section for details about the selectors.
buttonDefaults to left if invalid.
*modifiersModifier 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 Control, Alt, Shift and Meta. 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.
clickCountDefaults to 1.
delayTime to wait between mouse-down and mouse-up. Defaults to 0.
position_x position_yA point to click relative to the top-left corner of element bounding-box. Only positive values within the bounding-box are allowed. If not specified, clicks to some visible point of the element.
forceSet to True to skip Playwright's Actionability checks (https://playwright.dev/docs/actionability).
noWaitAfterActions 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.
trialWhen 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.

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.

Usage

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 noWaitAfter=True

Closes the current browser.

Arguments

ArgumentTypeDefault value
browserSelectionType, strCURRENT

Active browser is set to the browser that was active before this one. Closes all context and pages belonging to this browser. See Browser, Context and Page for more information about Browser and related concepts.

ArgumentDescription
browserBrowser to close. CURRENT selects the active browser. ALL closes all browsers. When a browser id is provided, that browser is closed.

Usage

Close Browser ALL # Closes all browsers Close Browser CURRENT # Close current browser Close Browser # Close current browser Close Browser ${id} # Close browser matching id

Closes a Context.

Arguments

ArgumentTypeDefault value
contextSelectionType, strCURRENT
browserSelectionType, strCURRENT

Active context is set to the context that was active before this one. Closes pages belonging to this context. See Browser, Context and Page for more information about Context and related concepts.

ArgumentDescription
contextContext to close. CURRENT selects the active context. ALL closes all contexts. When a context id is provided, that context is closed.
browserBrowser where to close context. CURRENT selects the active browser. ALL closes all browsers. When a browser id is provided, that browser is closed.

Usage

Close Context # Closes current context and current browser Close Context CURRENT CURRENT # Closes current context and current browser Close Context ALL CURRENT # Closes all context from current browser and current browser Close Context ALL ALL # Closes all context from current browser and all browser

Closes the page in context in browser.

Arguments

ArgumentTypeDefault value
pageSelectionType, strCURRENT
contextSelectionType, strCURRENT
browserSelectionType, strCURRENT
runBeforeUnloadboolFalse

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.

runBeforeUnload defines where to run the before unload page handlers. Defaults to false.

ArgumentDescription
pagePage to close. CURRENT selects the active page. ALL closes all pages. When a page id is provided, that page is closed.
contextContext where to close page. CURRENT selects the active context. ALL closes all contexts. When a context id is provided, that context is closed.
browserBrowser where to close page. CURRENT selects the active browser. ALL closes all browsers. When a browser id is provided, that browser is closed.

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

Connect to a playwright Browser.

Arguments

ArgumentTypeDefault value
wsEndpointstrnull
browserSupportedBrowserschromium

See Browser, Context and Page for more information about Browser and related concepts.

Returns a stable identifier for the connected browser.

ArgumentDescription
wsEndpointAddress to connect to.
browserOpens the specified browser. Defaults to chromium.

Web crawler is a tool to go through all the pages on a specific URL domain. This happens by finding all links going to the same site and opening those.

Arguments

ArgumentTypeDefault value
urlstr, NoneNone
page_crawl_keywordtake_screenshot
max_number_of_page_to_crawlint1000
max_depth_to_crawlint50

returns list of crawled urls.

ArgumentsDescription
urlis the page to start crawling from.
page_crawl_keywordis the keyword that will be executed on every page. By default it will take a screenshot on every page.
max_number_of_page_to_crawlis the upper limit of pages to crawl. Crawling will stop if the number of crawled pages goes over this.
max_depth_to_crawlis the upper limit of consecutive links followed from the start page. Crawling will stop if there are no more links under this depth.

Deletes all cookies from the currently active browser context.

Deselects all options from select element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
ArgumentsDescription
selectorSelector of the select tag. See the Finding elements section for details about the selectors.

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.

Download given url content.

Arguments

ArgumentTypeDefault value
urlstrnull

Keyword returns dictionary which contains downloaded file path and suggested filename as keys (saveAs and suggestedFilename). If the file URL cannot be found (the download is triggered by event handlers) use Wait For Downloadkeyword.

To enable downloads context's acceptDownloads needs to be true.

To configure download directory use New Browser's downloadsPath settings

With default filepath downloaded files are deleted when Context the download happened in is closed.

This keyword requires that there is currently an open page. The keyword uses the current pages local state (cookies, sessionstorage, localstorage) for the download to avoid authentication problems.

Usage

${file_object}= Download ${url} ${actual_size}= Get File Size ${file_object.saveAs}

Example 2:

${elem}= Get Element text="Download File" ${href}= Get Property ${elem} href ${file_object}= Download ${href} ${file_path}= Set Variable ${file_object.saveAs}

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

Arguments

ArgumentTypeDefault value
selector_fromstrnull
selector_tostrnull
stepsint1
ArgumentsDescription
selector_fromIdentifies the element, which center is the start-point.
selector_toIdentifies the element, which center is the end-point.
stepsDefines how many intermediate mouse move events are sent. Often it is nessesary to send more than one intermediate event to get the desired result. Defaults to 1.

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 boundingbox.

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

Example

Drag And Drop "Circle" "Goal"

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

Arguments

ArgumentTypeDefault value
from_xfloatnull
from_yfloatnull
to_xfloatnull
to_yfloatnull
stepsint1

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.

from_x & from_yIdentify the start-point on page.
to_x & to_yIdentify the end-point.
stepsDefines how many intermediate mouse move events are sent. Often it is nessesary to send more than one intermediate event to get the desired result. Defaults to 1.

Usage

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

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

Arguments

ArgumentTypeDefault value
selector_fromstrnull
xfloat0.0
yfloat0.0
stepsint1

This keyword can be handy to simulate swipe actions.

ArgumentsDescription
selector_fromidentifies the element, which center is the start-point.
x & yidentifies the end-point which is relative to the start-point.
stepsdefines how many intermediate mouse move events are sent. Often it is nessesary to send more than one intermediate event to get the desired result. Defaults to 1.

See the Finding elements section for details about the selectors.

First it moves the mouse to the start-point (center of boundingbox), 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 pixel to the left

Eat all cookies for all easter.

Executes given javascript on the selected element(s) or on page.

Arguments

ArgumentTypeDefault value
selectorstr, NoneNone
functionstrnull
argAny, NoneNone
all_elementsboolFalse
ArgumentsDescription
selectorSelector 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 elementHandle. For example (element) => document.activeElement === element See the Finding elements section for details about the selectors.
*functionA valid javascript function or a javascript function body. These arguments can be used to write readable multiline JavaScript.
argan additional argument that can be handed over to the JavaScript function. This argument must be JSON serializable. ElementHandles are not supported.
all_elementsdefines if only the single elementHandle found by selector is handed over to the function or if set to True all found elements are handed over as array.

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 if all_elements is False. See Finding elements for more details about strict mode.

Usage examples.

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

Arguments

ArgumentTypeDefault value
selectorstrnull
secretstrnull
forceboolFalse
ArgumentsDescription
secretThe secret string that should be filled into the text field.
selectorSelector of the text field. See the Finding elements section for details about the selectors.
forceSet to True to skip Playwright's [https://playwright.dev/docs/actionabilityActionability checks].

This keyword does not log secret in Robot Framework logs, when keyword resolves the secret variable internally. When secret variable is prefixed with $, without the curly braces, library will resolve the corresponding Robot Framework variable.

If secret variable is prefixed with %, library will resolve corresponding environment variable. Example $Password` will resolve to ${Password} Robot Framework variable. Also %ENV_PWD will resolve to %{ENV_PWD} environment variable.

Using normal Robot Framework variables like ${password} will not work!

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

This keyword will also work with a give cryptographic cipher text, that has been encrypted by Crypto library. See Crypto Library for more details.

If enable_playwright_debug is enabled in the library import, secret will be always visible as plain text in the playwright debug logs, regardless of the Robot Framework log level.

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

See Fill Text for other details.

Usage

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

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

Arguments

ArgumentTypeDefault value
selectorstrnull
txtstrnull
forceboolFalse

This method 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 selector is not an <input>, <textarea> or [contenteditable] element, this method throws an error. Note that you can pass an empty string as txt to clear the input field.

ArgumentsDescription
selectorSelector of the text field. See the Finding elements section for details about the selectors.
txtText for the text field.
forceSet to True to skip Playwright's [https://playwright.dev/docs/actionabilityActionability checks].

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

See Type Text for emulating typing text character by character.

Usage

Fill Text css=input#username_field username

Moves focus on to the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
ArgumentsDescription
selectorSelector of the element. See the Finding elements section for details about the selectors.

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

If there's no element matching selector, the method waits until a matching element appears in the DOM. Timeouts after 10 seconds.

Returns the HTML attribute of the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
attributestrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
selectorSelector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
attributeRequested attribute name.
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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 a 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 assert check the presents or the absents 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

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

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectednull
messagestr, NoneNone
ArgumentsDescription
selectorSelector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
*assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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

Optionally asserts that attribute names do match to the expected value. 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 accepts one single expected value

Other operators are not allowed.

Usage

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.

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

Arguments

ArgumentTypeDefault value
selectorstrnull
keyBoundingBoxFieldsALL
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
selectorSelector from which shall be retrieved. See the Finding elements section for details about the selectors.
keyOptionally 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_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

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 Get BoundingBox id=element width > 180 Get BoundingBox id=element ALL validate value['x'] > value['y']*2

Returns all browsers, open contexts in them and open pages in these contexts.

Arguments

ArgumentTypeDefault value
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone

See Browser, Context and Page for more information about these concepts.

ArgumentsDescription
assertion_operatorOptional assertion operator. See Assertions for more information.
assertion_expectedOptional expected value. See Assertions for more information.
messageOptional custom message to use on failure. See Assertions for more information.

The data is parsed into a python list containing data representing the open Objects.

On the root level the data contains a list of open browsers.

Data can be manipulated also with assertion_operator for example to find a specific id based on index or page title with then operator.

Return value can also be asserted against expected value.

Sample:

[ { "type": "chromium", "id": "browser=96207191-8147-44e7-b9ac-5e04f2709c1d", "contexts": [ { "type": "context", "id": "context=525d8e5b-3c4e-4baa-bfd4-dfdbc6e86089", "activePage": "page=f90c97b8-eaaf-47f2-98b2-ccefd3450f12", "pages": [ { "type": "page", "title": "Robocorp", "url": "https://robocorp.com/", "id": "page=7ac15782-22d2-48b4-8591-ff17663fa737", "timestamp": 1598607713.858 }, { "type": "page", "title": "Home - Reaktor", "url": "https://www.reaktor.com/", "id": "page=f90c97b8-eaaf-47f2-98b2-ccefd3450f12", "timestamp": 1598607714.702 } ] } ], "activeContext": "context=525d8e5b-3c4e-4baa-bfd4-dfdbc6e86089", "activeBrowser": false }, { "type": "firefox", "id": "browser=ad99abac-17a9-472b-ac7f-d6352630834e", "contexts": [ { "type": "context", "id": "context=bc64f1ba-5e76-46dd-9735-4bd344afb9c0", "activePage": "page=8baf2991-5eaf-444d-a318-8045f914e96a", "pages": [ { "type": "page", "title": "Software-Qualitätssicherung und Softwaretest", "url": "https://www.imbus.de/", "id": "page=8baf2991-5eaf-444d-a318-8045f914e96a", "timestamp": 1598607716.828 } ] } ], "activeContext": "context=bc64f1ba-5e76-46dd-9735-4bd344afb9c0", "activeBrowser": true } ]

Returns a list of ids from open browsers. See Browser, Context and Page for more information about Browser and related concepts.

Arguments

ArgumentTypeDefault value
browserSelectionTypeALL

browser Defaults to ALL

  • ALL / ANY Returns all ids as a list.
  • ACTIVE / CURRENT Returns the id of the currently active browser as list.
ArgumentsDescription
browserThe browser to get the ids from. ALL for all open browsers, ACTIVE for the currently active browser or the id of the browser to get the ids from.

The ACTIVE browser is a synonym for the CURRENT Browser.

Returns the state of the checkbox found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedbool, strUnchecked
messagestr, NoneNone

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

ArgumentsDescription
selectorSelector which shall be examined. See the Finding elements section for details about the selectors.
assertion_operator== and != and equivalent are allowed on boolean values. Other operators are not accepted.
assertion_expectedBoolean value of expected state. Strings are interpreted as booleans. All strings are ${True} except of the following FALSE, NO, OFF, 0, UNCHECKED, NONE, ${EMPTY}` (case-insensitive). Defaults to unchecked.
messageoverrides the default error message for assertion.
  • checked => True
  • unchecked => False

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

Usage

Get Checkbox State [name=can_send_email] == checked

Returns all classes of an element as a list.

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectednull
messagestr, NoneNone
ArgumentsDescription
selectorSelector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
*assertion_expectedExpected values for the state
messageoverrides the default error message for assertion.

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 accepts one single expected value

Other operators are not allowed.

Usage

Get Classes id=draggable == react-draggable box # Element contains exactly this class name. Get Classes id=draggable validate "react-draggable-dragged" not in value # Element does not contain react-draggable-dragged class.

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

Arguments

ArgumentTypeDefault value
selectorstr, NoneNone
keySizeFieldsALL
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
selectorOptional selector from which 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.
keyOptionally 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_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

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.

Returns the console log of the active page.

Arguments

ArgumentTypeDefault value
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
null
fullboolFalse
lastint, timedelta, NoneNone

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

ArgumentsDescription
assertion_operatorOptional assertion operator. See Assertions for more information.
assertion_expectedOptional expected value. See Assertions for more information.
messageOptional custom message to use on failure. See Assertions for more information.
fullIf true, returns the full console log. If false, returns only new entries that were added since last time.
lastIf set, returns only the last n entries. Can be int for number of entries or timedelta for time period.

The returned data is a list of log messages.

A log message is a dict with the following structure:

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

Usage

[{ '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:

KeyDescription
typeOne of the following values: log, debug, info, error, warning, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd
textThe text of the console message.
location.urlThe URL of the resource that generated this message.
location.lineNumberThe line number in the resource that generated this message (0-based).
location.columnNumberThe column number in the resource that generated this message (0-based).
timeThe timestamp of the log message as ISO 8601 string.

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

Arguments

ArgumentTypeDefault value
contextSelectionTypeALL
browserSelectionTypeALL

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

ArgumentsDescription
contextThe context to get the ids from. ALL will return all ids from selected browser(s), ACTIVE for the one active context of each selected browser.
browserThe browser to get the context ids from. ALL Context ids from all open browsers shall be fetched. ACTIVE Only context ids from the active browser shall be fetched.

The ACTIVE context of the ACTIVE Browser is the Current Context.

Returns cookies from the current active browser context.

Arguments

ArgumentTypeDefault value
return_typeCookieTypedictionary

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

If return_type is string or str, then keyword returns the cookie as a string in format: name1=value1; name2=value2; name3=value3. The return value contains only name and value keys of the cookie.

Get a single device descriptor with name exactly matching name.

Arguments

ArgumentTypeDefault value
namestrnull
ArgumentsDescription
nameGiven name of the requested device. See Playwright's deviceDescriptorsSource.json for a formatted list.

Allows a concise syntax to set website testing values to exact matches of specific mobile devices.

Use by passing to a context. After creating a context with devicedescriptor, before using ensure your active page is on that context. Usage:

${device}= Get Device iPhone X New Context &{device} New Page Get Viewport Size # returns { "width": 375, "height": 812 }

Returns a dict of all playwright device descriptors.

See Playwright's deviceDescriptorsSource.json for a formatted list.

Returns a reference to a Playwright Locator.

Arguments

ArgumentTypeDefault value
selectorstrnull

The reference can be used in subsequent selectors.

ArgumentsDescription
selectorSelector from which shall be retrieved . See the Finding elements section for details about the selectors.

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

Usage

${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.

Allows locating elements by their features.

Arguments

ArgumentTypeDefault value
selection_strategySelectionStrategynull
textstr, RegExpnull
exactboolFalse
all_elementsboolFalse

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

ArgumentsDescription
locator_typeSelectionStrategy to be used. Refers to Playwrights page.getBy*** functions. See https://playwright.dev/docs/locators
textText to locate the element for.
exactWhether to find an exact match: case-sensitive and whole-string. Default 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_elementsIf True, returns all matched elements as a list.

This keywords implements the following Playwright functions:

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

Returns a reference to Playwright Locator for the matched element by role or a list of references if all_elements is set to True.

Arguments

ArgumentTypeDefault value
roleElementRolenull
null
all_elementsboolFalse
checkedbool, NoneNone
disabledbool, NoneNone
exactbool, NoneNone
expandedbool, NoneNone
include_hiddenbool, NoneNone
levelint, NoneNone
namestr, RegExp, NoneNone
pressedbool, NoneNone
selectedbool, NoneNone

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 it's 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
ArgumentsDescription
all_elementsIf True, returns all matched elements as a list.
roleRole from which shall be retrieved.
checkedAn attribute that is usually set by aria-checked or native <input type=checkbox> controls.
disabledAn attribute that is usually set by aria-disabled or disabled.
exactWhether 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.
expandedAn attribute that is usually set by aria-expanded.
include_hiddenOption that controls whether hidden elements are matched. By default, only non-hidden elements, as defined by ARIA, are matched by role selector.
levelA number attribute that is usually present for roles heading, list item, row, treeitem, with default values for <h1>-<h6> elements.
nameOption to match the accessible name. By default, matching is case-insensitive and searches for a substring, use exact to control this behavior.
pressedAn attribute that is usually set by aria-pressed.
selectedAn attribute that is usually set by aria-selected.

Returns the count of elements found with selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedint, str0
messagestr, NoneNone
ArgumentsDescription
selectorSelector which shall be counted. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

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

Usage

Get Element Count label > 1

Get the active states from the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedElementState, strnull
messagestr, NoneNone
return_namesTrue

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

ArgumentsDescription
selectorSelector of the corresponding object. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
*assertion_expectedExpected states
messageoverrides the default error message for assertion.
return_namesIf set to False the keyword does return an IntFlag object instead of a list. Defaults to True.

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 contain the states as ElementState.

Usage

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. Select elements have also either selected or unselected.

The state of animating will be set if an element is not considered stable within 300 ms.

If an element is not attached to the dom, so 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.

Returns a reference to Playwright Locator for all matched elements by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
ArgumentsDescription
selectorSelector from which shall be retrieved. See the Finding elements section for details about the selectors.

Usage

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

Returns the page errors of the active page.

Arguments

ArgumentTypeDefault value
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
null
fullboolFalse
lastint, timedelta, NoneNone

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

ArgumentsDescription
assertion_operatorOptional assertion operator. See Assertions for more information.
assertion_expectedOptional expected value. See Assertions for more information.
messageOptional custom message to use on failure. See Assertions for more information.
fullIf true, returns the full console log. If false, returns only new entries that were added since last time.
lastIf set, returns only the last n entries. Can be int for number of entries or timedelta for time period.

The returned data is a list of error messages.

An error message is a dict with the following structure:

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

Usage

[{ '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:

KeyDescription
nameThe name/type of the error.
messageThe human readable error message.
stackThe stack trace of the error, if given.
timeThe timestamp of the error as ISO 8601 string.

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.

Arguments

ArgumentTypeDefault value
pageSelectionTypeALL
contextSelectionTypeALL
browserSelectionTypeALL

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

ArgumentsDescription
pageThe 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.
contextThe context 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.
browserThe browser 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.

Usage

Test Case New Page http://www.imbus.de New Page http://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}

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

Gets pages HTML source as a string.

Arguments

ArgumentTypeDefault value
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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

Returns the property of the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
propertystrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
selectorSelector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
propertyRequested property name.
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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 property is not found, value is None and Keyword does not fail. See Get Attribute for examples.

Usage

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

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

Arguments

ArgumentTypeDefault value
selectorstr, NoneNone
keyAreaFieldsALL
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone

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

ArgumentsDescription
selectorOptional selector from which 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.
keyOptionally 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_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

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.

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

Arguments

ArgumentTypeDefault value
selectorstr, NoneNone
keySizeFieldsALL
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
selectorOptional selector from which 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.
keyOptionally 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_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

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 Width: ${height} # Height: 58425 ${scroll_size}= Get Scroll Size id=keyword-shortcuts-container # unfiltered element Log ${scroll_size} # {'width': 253, 'height': 3036}

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

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone

Returned dictionaries have the following keys and their values "index", "value", "label" and "selected".

ArgumentsDescription
selectorSelector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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.

Usage

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)

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

Arguments

ArgumentTypeDefault value
selectorstrnull
option_attributeSelectAttributelabel
assertion_operatorAssertionOperator, NoneNone
assertion_expectednull
messagestr, NoneNone
ArgumentsDescription
selectorSelector from which the info is to be retrieved. See the Finding elements section for details about the selectors.
option_attributeWhich attribute shall be returned/verified. Defaults to label.
assertion_operatorSee Assertions for further details. Defaults to None.
*assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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 accepts one single expected value

Other operators are not allowed.

Usage

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

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

Arguments

ArgumentTypeDefault value
selectorstrnull
keystr, NoneALL
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
pseudo_elementstr, NoneNone

Optionally matches with any sequence assertion operator.

ArgumentsDescription
selectorSelector from which the style shall be retrieved. See the Finding elements section for details about the selectors.
keyKey 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_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.
pseudo_elementPseudo element to match. Defaults to None. Pseudo elements are special css

Pseudo element is a css fuctionality to add styles. 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.

Returns the Web Element that has the same column index and same row index as the selected elements.

Arguments

ArgumentTypeDefault value
tablestrnull
columnstrnull
rowstrnull
ArgumentsDescription
tableselector must select the <table> element that contains both selected elements
columnselector can select any <th> or <td> element or one of their descendants.
rowselector can select any <tr> element or one of their descendant like <td> elements.

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 table selector like this: f"{table} >> {row}" .

GitHubSlackReal Name
mkorpela@mkorpelaMikko Korpela
aaltat@aaltatTatu Aalto
xylix@Kerkko PelttariKerkko Pelttari
Snooz82@RenéRené Rohner

Usage

${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

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

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedint, str0
messagestr, NoneNone
ArgumentsDescription
selectorcan select any <th> or <td> element or one of their descendants. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

Usage

${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.

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

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedint, str0
messagestr, NoneNone
ArgumentsDescription
selectorcan select any <th> or <td> element or one of their descendants. See the Finding elements section for details about the selectors.
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

Usage

${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.

Returns text attribute of the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone

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

ArgumentsDescription
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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

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

Usage

${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.

Returns the title of the current page.

Arguments

ArgumentTypeDefault value
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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

Returns the current URL.

Arguments

ArgumentTypeDefault value
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
assertion_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the state
messageoverrides the default error message for assertion.

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

Returns the current viewport dimensions.

Arguments

ArgumentTypeDefault value
keySizeFieldsALL
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
ArgumentsDescription
keyOptionally 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_operatorSee Assertions for further details. Defaults to None.
assertion_expectedExpected value for the counting
messageoverrides the default error message for assertion.

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

Usage

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

Navigates to the previous page in history.

Navigates to the next page in history.

Navigates to the given url.

Arguments

ArgumentTypeDefault value
urlstrnull
timeouttimedelta, NoneNone
ArgumentsDescription
url<str> URL to be navigated to.
timeout<str> time to wait page to load. If not defined will use the library default timeout.

Grants permissions to the current context.

Arguments

ArgumentTypeDefault value
permissionsPermissionnull
originstr, NoneNone
ArgumentsDescription
permissionsis a list of permissions to grant. Permissions can be one of the following: geolocation, notifications, camera, microphone,
originThe origin to grant permissions to, e.g. "https://example.com".

Usage

New Context Grant Permissions geolocation

Handle next dialog on page with action.

Arguments

ArgumentTypeDefault value
actionDialogActionnull
prompt_inputstr

Dialog can be any of alert, beforeunload, confirm or prompt. Handling dialogue must be called before the action, like example click, that triggers the dialogue.

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

ArgumentsDescription
actionHow to handle the alert. Can be accept or dismiss.
prompt_inputThe value to enter into prompt. Only valid if action argument equals accept. Defaults to empty string.

Usage

Handle Future Dialogs action=accept Click \#alerts

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

Arguments

ArgumentTypeDefault value
selectorstrnull
durationtimedelta0:00:05
widthstr2px
stylestrdotted
colorstrblue

Returns the number of highlighted elements. Keyword does not fail, if locator 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.

ArgumentsDescription
selectorSelectors which shall be highlighted. See the Finding elements section for details about the selectors.
durationSets for how long the selector shall be highlighted. Defaults to 5s => 5 seconds.
widthSets the width of the higlight border. Defaults to 2px.
styleSets the style of the border. Defaults to dotted.
colorSets the color of the border. Valid colors i.e. are: red, blue, yellow, pink, black

Keyword does not fail if selector resolves to multiple elements.

Usage

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}

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

Arguments

ArgumentTypeDefault value
selectorstrnull
position_xfloat, NoneNone
position_yfloat, NoneNone
forceboolFalse
modifiersKeyboardModifiernull

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

  • Find an element match 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 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.
ArgumentsDescription
selectorSelector element to hover. See the Finding elements section for details about the selectors.
position_x & position_yA 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.
forceSet to True to skip Playwright's [https://playwright.dev/docs/actionabilityActionability checks].
*modifiersModifier 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.

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

Usage

Hover h1 Hover h1 10 20 Alt

Performs an HTTP request in the current browser context

Arguments

ArgumentTypeDefault value
urlstrnull
methodRequestMethodGET
bodystr, NoneNone
headersdict, NoneNone
ArgumentsDescription
urlThe request url, e.g. /api/foo.
methodThe HTTP method for the request. Defaults to GET.
bodyThe request body. GET requests cannot have a body. If the body can be parsed as JSON, the Content-Type header for the request will be automatically set to application/json. Defaults to None.
headersA dictionary of additional request headers. Defaults to None.

The response is a Python dictionary with following attributes:

  • status <int> The status code of the response.
  • statusText <str> Status text corresponding to status, e.g OK or INTERNAL SERVER ERROR.
  • body <dict> | <str> The response body. If the body can be parsed as a JSON obejct, 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 successfull, i.e. the status is range 200-299.

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

Input text into page with virtual keyboard.

Arguments

ArgumentTypeDefault value
actionKeyboardInputActionnull
inputstrnull
delayint, timedelta0:00:00
ArgumentsDescription
actioninsertText: 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.
inputThe inputstring to be typed. No special keys possible.
delayTime to wait between key presses in Robot Framework's time format. Defaults to 0.

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.press. Modifier keys DO NOT effect these methods. For testing modifier effects use single key presses with Keyboard Key press

Usage

Keyboard Input insertText 0123456789

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

Arguments

ArgumentTypeDefault value
actionKeyActionnull
keystrnull
ArgumentsDescription
actionDetermine whether the key should be released (up), hold (down) or pressed once (press). down or up are useful for combinations i.e. with Shift.
keyThe key to be pressed. An example 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.

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

Example excecution:

Keyboard Key press S 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.

Remove all saved data from the local storage.

Arguments

ArgumentTypeDefault value
frame_selectorstr, NoneNone
ArgumentsDescription
frame_selectorIf this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

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

Get saved data from the local storage.

Arguments

ArgumentTypeDefault value
keystrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
frame_selectorstr, NoneNone
ArgumentsDescription
keyNamed key of the item in the storage.
assertion_operatorAssertion operator to use. See Assertions for more information.
assertion_expectedExpected value to compare with.
messageCustom error message to use.
frame_selectorIf this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

See Assertions for further details for the assertion arguments. Defaults to None.

Usage

Local Storage Get Item Key == Value My error ${value} = Local Storage Get Item Key

Remove saved data with key from the local storage.

Arguments

ArgumentTypeDefault value
keystrnull
frame_selectorstr, NoneNone
ArgumentsDescription
keyThe name of the item which shall be deleted.
frame_selectorIf this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

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

Save data to the local storage.

Arguments

ArgumentTypeDefault value
keystrnull
valuestrnull
frame_selectorstr, NoneNone
ArgumentsDescription
keyThe name of the key under which it should be saved.
valueThe value which shall be saved as a string.
frame_selectorIf this selector points to an element inside an iframe, the LocalStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

Local Storage Set Item Key Value

Clicks, presses or releases a mouse button.

Arguments

ArgumentTypeDefault value
actionMouseButtonActionnull
xfloat, NoneNone
yfloat, NoneNone
buttonMouseButtonleft
clickCountint1
delayint, timedelta0:00:00
ArgumentsDescription
actionDefines if it is a mouseclick (click), holding down a button (down) or releasing it (up).
x, yCoordinates to move before action is executed.
buttonOne of left, middle or up. Defaults to left.
clickCountDetermine how often the button shall be clicked if action is equal to click. Defaults to 1.
delayDelay in Robot Framework time format between the mousedown and mouseup event. Can only be set if the action is click.

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 100 ms Mouse Button click ${dyn_delay} ms

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

Usage

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

Instead of selectors command mouse with coordinates. The Click commands will leave the virtual mouse on the specified coordinates.

Arguments

ArgumentTypeDefault value
xfloatnull
yfloatnull
stepsint1
ArgumentsDescription
x & yAre absolute coordinates starting at the top left of the page.
stepsNumber of intermediate steps for the mouse event. Often it is nessesary to send more than one intermediate event to get the desired result. Defaults to 1.

Usage

Mouse Move 400 400

Moves the mouse cursor relative to the selected element.

Arguments

ArgumentTypeDefault value
selectorstrnull
xfloat0.0
yfloat0.0
stepsint1
ArgumentsDescription
selectorIdentifies the element, which center is the start-point.
x & yAre relative coordinates to the center of the elements bounding box.
stepsNumber of intermediate steps for the mouse event. Often it is nessesary to send more than one intermediate event to get the desired result. Defaults to 1.

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

Usage

Mouse Move Relative To id=indicator -100

Simulates the user rotation of a mouse wheel.

Arguments

ArgumentTypeDefault value
deltaXintnull
deltaYintnull
ArgumentsDescription
deltaX & deltaYPixels that are scrolled horizontally & vertically.

Usage

Hover body Mouse Wheel 0 250

Create a new playwright Browser with specified options.

Arguments

ArgumentTypeDefault value
browserSupportedBrowserschromium
headlessboolTrue
null
argsList[str], NoneNone
channelstr, NoneNone
chromiumSandboxboolFalse
devtoolsboolFalse
downloadsPathstr, NoneNone
envDict, NoneNone
executablePathstr, NoneNone
firefoxUserPrefsDict[str, str | int | float | bool], NoneNone
handleSIGHUPboolTrue
handleSIGINTboolTrue
handleSIGTERMboolTrue
ignoreDefaultArgsList[str], bool, NoneNone
proxyProxy, NoneNone
reuse_existingboolTrue
slowMotimedelta0:00:00
timeouttimedelta0:00:30

See Browser, Context and Page for more information about Browser and related concepts.

Returns a stable identifier for the created browser.

ArgumentsDescription
browserOpens the specified browser. Defaults to chromium.
headlessSet to False if you want a GUI. Defaults to True.
argsAdditional arguments to pass to the browser instance. The list of Chromium flags can be found here. Defaults to None.
channelAllows to operate against the stock Google Chrome and Microsoft Edge browsers. For more details see: Playwright documentation.
chromiumSandboxEnable Chromium sandboxing. Defaults to False.
devtoolsChromium-only Whether to auto-open a Developer Tools panel for each tab.
downloadsPathIf specified, accepted downloads are downloaded into this folder. Otherwise, temporary folder is created and is deleted when browser is closed.
envSpecifies environment variables that will be visible to the browser. Dictionary keys are variable names, values are the content. Defaults to None.
executablePathPath to a browser executable to run instead of the bundled one. If executablePath is a relative path, then it is resolved relative to current working directory. Note that Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk. Defaults to None.
firefoxUserPrefs |Firefox user preferences. Learn more about the Firefox user preferences at about:config.
handleSIGHUPClose the browser process on SIGHUP. Defaults to True.
handleSIGINTClose the browser process on Ctrl-C. Defaults to True.
handleSIGTERMClose the browser process on SIGTERM. Defaults to True.
ignoreDefaultArgsIf True, Playwright does not pass its own configurations args and only uses the ones from args. If a list is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to False.
proxyNetwork Proxy settings. Structure: {'server': <str>, 'bypass': <Optional[str]>, 'username': <Optional[str]>, 'password': <Optional[str]>}
reuse_existingIf set to True, an existing browser instance, that matches the same arguments, will be reused. If no same configured Browser exist, a new one is started. Defaults to True.
slowMoSlows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to no delay.
timeoutMaximum time in Robot Framework time format to wait for the browser instance to start. Defaults to 30 seconds. Pass 0 to disable timeout.

Create a new BrowserContext with specified options.

Arguments

ArgumentTypeDefault value
null
acceptDownloadsboolTrue
baseURLstr, NoneNone
bypassCSPboolFalse
colorSchemeColorScheme, NoneNone
defaultBrowserTypeSupportedBrowsers, NoneNone
deviceScaleFactorfloat, NoneNone
extraHTTPHeadersDict[str, str], NoneNone
forcedColorsForcedColorsnone
geolocationGeoLocation, NoneNone
hasTouchbool, NoneNone
hideRfBrowserDeprecated
httpCredentialsHttpCredentials, NoneNone
ignoreHTTPSErrorsboolFalse
isMobilebool, NoneNone
javaScriptEnabledboolTrue
localestr, NoneNone
offlineboolFalse
permissionsList[Permission], NoneNone
proxyProxy, NoneNone
recordHarRecordHar, NoneNone
recordVideoRecordVideo, NoneNone
reducedMotionReduceMotionno_preference
screenDict[str, int], NoneNone
serviceWorkersServiceWorkersPermissions, Noneallow
storageStatestr, NoneNone
timezoneIdstr, NoneNone
tracingstr, NoneNone
userAgentstr, NoneNone
viewportViewportDimensions, None{'width': 1280, 'height': 720}

See Browser, Context and Page for more information about BrowserContext.

Returns a stable identifier for the created context that can be used in Switch Context.

ArgumentsDescription
acceptDownloadsWhether to automatically download all the attachments. Defaults to True where all the downloads are accepted.
baseURLWhen using Go To, Wait For Request or Wait For Response it takes the base URL in consideration by using the URL() constructor for building the corresponding URL. Unset by default. Examples: baseURL=http://localhost:3000 and navigating to /bar.html results in http://localhost:3000/bar.html. baseURL=http://localhost:3000/foo/ and navigating to ./bar.html results in http://localhost:3000/foo/bar.html. baseURL=http://localhost:3000/foo (without trailing slash) and navigating to ./bar.html results in http://localhost:3000/bar.html.
bypassCSPToggles bypassing page's Content-Security-Policy. Defaults to False.
colorSchemeEmulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference'.
defaultBrowserTypeIf no browser is open and New Context opens a new browser with defaults, it now uses this setting. Very useful together with Get Device keyword.
deviceScaleFactorSpecify device scale factor (can be thought of as dpr). Defaults to 1.
extraHTTPHeadersA dictionary containing additional HTTP headers to be sent with every request. All header values must be strings.
forcedColorsEmulates forced-colors media feature, supported values are active and none.
geolocationA dictionary containing latitude and longitude or accuracy to emulate. If latitude or longitude is not specified, the device geolocation won't be overriden.
hasTouchSpecifies if viewport supports touch events. Defaults to False.
hideRfBrowserDEPRECATED --has no function--
httpCredentialsCredentials for HTTP authentication.
ignoreHTTPSErrorsWhether to ignore HTTPS errors during navigation. Defaults to False.
isMobileWhether the meta viewport tag is taken into account and touch events are enabled. Defaults to False.
javaScriptEnabledWhether or not to enable JavaScript in the context. Defaults to True.
localeSpecify user locale, for example en-GB, de-DE, etc.
offlineToggles browser's offline mode. Defaults to False.
permissionsA dictionary containing permissions to grant to all pages in this context. All permissions that are not listed here will be automatically denied.
proxyNetwork proxy settings to use with this context. Defaults to None. NOTE: For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example proxy={ server: 'http://per-context' }.
recordHarEnables HAR recording for all pages into to a file. Must be path to file, example ${OUTPUT_DIR}/har.file. If not specified, the HAR is not recorded. Make sure to await context to close for the to be saved.
recordVideoEnables video recording for all pages into a folder. If not specified videos are not recorded. Make sure to close context for videos to be saved.
reduceMotionEmulates prefers-reduced-motion media feature, supported values are reduce, no-preference.
screenEmulates consistent window screen size available inside web page via window.screen. Is only used when the viewport is set. Example {'width': 414, 'height': 896}
serviceWorkersWhether to allow sites to register Service workers. Defaults to 'allow'.
storageStateRestores the storage stated created by the Save Storage State keyword. Must mbe full path to the file.
timezoneIdChanges the timezone of the context. See ICU`s metaZones.txt for a list of supported timezone IDs.
tracingFile name where the tracing file is saved. Example trace.zip will be saved to ${OUTPUT_DIR}/traces.zip. Temporary trace files will be saved to ${OUTPUT_DIR}/Browser/traces. If file name is defined, tracing will be enabled for all pages in the context. Tracing is automatically closed when context is closed. Temporary trace files will be automatically deleted at start of each test execution. Trace file can be opened after the test execution by running command from shell: rfbrowser show-trace -F /path/to/trace.zip.
userAgentSpecific user agent to use in this context.
viewportA dictionary containing width and height. Emulates consistent viewport for each page. Defaults to 1280x720. null disables the default viewport. If width and height is 0, the viewport will scale with the window.

Usage

Test an iPhone ${device}= Get Device iPhone X New Context &{device} # unpacking here with & New Page http://example.com

A BrowserContext is the Playwright object that controls a single browser profile. Within a context caches and cookies are shared. See Playwright browser.newContext for a list of supported options.

If there's no open Browser this keyword will open one. Does not create pages.

Open a new Page.

Arguments

ArgumentTypeDefault value
urlstr, NoneNone

A Page is the Playwright equivalent to a tab. See Browser, Context and Page for more information about Page concept.

ArgumentsDescription
urlOptional URL to navigate the page to. The url should include protocol, e.g. https://

Returns NewPageDetails as dictionary for created page. NewPageDetails (dict) contains the keys page_id and video_path. page_id is a stable identifier for the created page. video_path is path to the created video or empty if video is not created.

When a New Page is called without an open browser, New Browser and New Context are executed with default values first.

Open a new persistent context.

Arguments

ArgumentTypeDefault value
userDataDirstr
browserSupportedBrowserschromium
headlessboolTrue
null
acceptDownloadsboolTrue
argsList[str], NoneNone
baseURLstr, NoneNone
bypassCSPboolFalse
channelstr, NoneNone
chromiumSandboxboolFalse
colorSchemeColorScheme, NoneNone
defaultBrowserTypeSupportedBrowsers, NoneNone
deviceScaleFactorfloat, NoneNone
devtoolsboolFalse
downloadsPathstr, NoneNone
envDict, NoneNone
executablePathstr, NoneNone
extraHTTPHeadersDict[str, str], NoneNone
forcedColorsForcedColorsnone
geolocationGeoLocation, NoneNone
handleSIGHUPboolTrue
handleSIGINTboolTrue
handleSIGTERMboolTrue
hasTouchbool, NoneNone
hideRfBrowserDeprecated
httpCredentialsHttpCredentials, NoneNone
ignoreDefaultArgsList[str], bool, NoneNone
ignoreHTTPSErrorsboolFalse
isMobilebool, NoneNone
javaScriptEnabledboolTrue
localestr, NoneNone
offlineboolFalse
permissionsList[Permission], NoneNone
proxyProxy, NoneNone
recordHarRecordHar, NoneNone
recordVideoRecordVideo, NoneNone
reducedMotionReduceMotionno_preference
screenDict[str, int], NoneNone
serviceWorkersServiceWorkersPermissions, Noneallow
slowMotimedelta0:00:00
storageStateDeprecated
timeouttimedelta0:00:30
timezoneIdstr, NoneNone
tracingstr, NoneNone
urlstr, NoneNone
userAgentstr, NoneNone
viewportViewportDimensions, None{'width': 1280, 'height': 720}

New Persistent Context does basically executes New Browser, New Context and New Page in one step with setting a profile at the same time.

This keyword returns a tuple of browser id, context id and page details. (New in Browser 15.0.0)

ArgumentDescription
userDataDirPath to a User Data Directory, which stores browser session data like cookies and local storage. More details for Chromium and Firefox. Note that Chromium's user data directory is the parent directory of the "Profile Path" seen at chrome://version. Pass an empty string to use a temporary directory instead.
browserBrowser type to use. Default is Chromium.
headlessWhether to run browser in headless mode. Defaults to True.
storageState & hideRfBrowserThese arguments have no function and will be removed soon.
other argumentsPlease see New Browser, New Context and New Page for more information about the other arguments.

If you want to use extensions you need to download the extension as a .zip, enable loading the extension, and load the extensions using chromium arguments like below. Extensions only work with chromium and with a headful browser.

${launch_args}= Set Variable ["--disable-extensions-except=./ublock/uBlock0.chromium", "--load-extension=./ublock/uBlock0.chromium"] ${browserId} ${contextId} ${pageDetails}= New Persistent Context browser=chromium headless=False url=https://robocon,io args=${launch_args}

Check New Browser, New Context and New Page for the specific argument docs.

Opens a new browser instance. Use this keyword for quick experiments or debugging sessions.

Arguments

ArgumentTypeDefault value
urlstr, NoneNone
browserSupportedBrowserschromium
headlessboolFalse
pause_on_failureboolTrue
bypassCSPTrue

Use New Page directly instead of Open Browser for production and automated execution. See Browser, Context and Page for more information about Browser and related concepts.

Creates a new browser, context and page with specified settings.

ArgumentDescription
urlNavigates to URL if provided. Defaults to None.
browserSpecifies which browser to use. The supported browsers are listed in the table below.
headlessIf set to False, a GUI is provided otherwise it is hidden. Defaults to False.
pause_on_failureStop execution when failure detected and leave browser open. Defaults to True.
bypassCSPDefaults to bypassing CSP and enabling custom script attach to the page.

Browsers:

ValueName(s)
firefoxFirefox
chromiumChromium
webkitwebkit

Types the given key combination into element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
keysstrnull
ArgumentsDescription
selectorSelector of the text field. See the Finding elements section for details about the selectors.
*keysKeys to be press after each other. Using + to chain combine modifiers with a single keypress Control+Shift+T is supported.

Supports values like "a, 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.

Usage

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

Wrap a Browser library keyword and make it a promise.

Arguments

ArgumentTypeDefault value
kwstrnull
argsnull

Promised keyword is executed and started on background. Test execution continues without waiting for kw to finish.

Returns reference to the promised keyword.

kw Keyword that will work async on background.

ArgumentsDescription
kwKeyword that will work async on background.
*argsKeyword arguments as normally used.

Usage

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

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

Arguments

ArgumentTypeDefault value
pathPathLikenull

Fails if the upload has not happened during timeout.

Upload file from path into next file chooser dialog on page.

ArgumentsDescription
pathPath to file to be uploaded.

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 Upload File By Selector keyword.

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

Arguments

ArgumentTypeDefault value
saveAsstr

If you can get the URL for the file to download, Download keyword should be a consistent way to download the file.

To enable downloads context's acceptDownloads needs to be true.

To configure download directory use New Browser's downloadsPath settings

With default filepath downloaded files are deleted when Context the download happened in is closed.

ArgumentsDescription
saveAsDefines path where the file is saved. File will also temporarily be saved in playwright context's default download location.

Waited promise returns a dictionary which contains saveAs and suggestedFilename as keys. The saveAs contains where the file is downloaded and suggestedFilename contains the name 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 Click \#file_download ${file_obj}= Wait For ${dl_promise} File Should Exist ${file_obj}[saveAs] Should Be True ${file_obj.suggestedFilename}

Record the selector that is under mouse.

Arguments

ArgumentTypeDefault value
labelstr, NoneNone
ArgumentsDescription
labeltext to show when on the box in the page while recording.

Focus on the page and move mouse over the element you want to select.

Usage

${selector} = Record Selector Button Click ${selector} ${selector2} = Record Selector Page header Get Text ${selector2} == Expected text

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

Arguments

ArgumentTypeDefault value
keywordstr, Nonenull
argsstrnull
scopeScopeGlobal
ArgumentsDescription
keywordThe 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.
*argsThe arguments to the keyword if any.
scopeScope defines the live time of this setting. Available values are Global, Suite or Test / Task. See Scope Settings for more details.

The initial keyword to use is set when importing the library, and the keyword that is used by default is Take Screenshot. 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 the previously registered failure keyword. The return value can be always used to restore the original value later. The returned object contains keyword name and the possible arguments used to for the keyword.

Usage

Register Keyword To Run On Failure Take Screenshot ${previous kw}= Register Keyword To Run On Failure NONE 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

Reloads current active page.

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. Keyword retrieves the storage state from authenticated contexts and save it to disk. Then New Context can be created with prepopulated state.

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

The file is created in ${OUTPUTDIR}/browser/state folder and file(s) are automatically deleted when new test execution starts. File path is returned by the keyword.

Usage

Test Case New context New Page https://login.page.html # Perform login 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

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

Arguments

ArgumentTypeDefault value
selectorstr, NoneNone
verticalstrheight
horizontalstr0
behaviorScrollBehaviorauto
ArgumentsDescription
selectorSelector 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.
verticaldefines 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 defining to scroll exactly one visible height down or up with -height. 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.
horizontaldefines where to scroll horizontally. Works same as vertical but defines positive values for right and negative values for left. width defines to scroll exactly one visible range to the right.
behaviordefines whether the scroll happens directly or it scrolls smoothly.

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

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

Arguments

ArgumentTypeDefault value
selectorstr, NoneNone
verticalstrtop
horizontalstrleft
behaviorScrollBehaviorauto
ArgumentsDescription
selectorSelector 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.
verticaldefines 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 that top or the bottom of the scroll area. < topbottom > Be aware that some pages do lazy loading and load more content once you scroll down. Bottom defines the current known bottom coordinate.
horizontaldefines where to scroll horizontally. Works same as vertical but defines < leftright > as start and end.
behaviordefines whether the scroll happens directly or it scrolls smoothly.

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

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

Arguments

ArgumentTypeDefault value
selectorstrnull
ArgumentsDescription
selectorSelector of the checkbox. See the Finding elements section for details about the selectors.

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

Does nothing if the element is already visible.

Selects options from select element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
attributeSelectAttributenull
valuesnull
ArgumentsDescription
selectorSelector of the <select> tag. See the Finding elements section for details about the selectors.
attributeAttribute to select options by. Can be value, label, text or index. Where label and text are same.
*valuesValues to select.

Returns list of options which keyword was able to select. The type of list item matches to attribute definition. Example if attribute equals to label returned list contains label values. Or in case of index it contains list of selected indexes.

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

If no values to select are passed will deselect options in element.

Usage

${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

Remove all saved data from the session storage.

Arguments

ArgumentTypeDefault value
frame_selectorstr, NoneNone
ArgumentsDescription
frame_selectorIf this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

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

Get saved data from from session storage.

Arguments

ArgumentTypeDefault value
keystrnull
assertion_operatorAssertionOperator, NoneNone
assertion_expectedAny, NoneNone
messagestr, NoneNone
frame_selectorstr, NoneNone
ArgumentsDescription
keyNamed key of the item in the storage.
assertion_operatorAssertion operator to use. See Assertions for more information.
assertion_expectedExpected value to compare with.
messageCustom error message to use.
frame_selectorIf this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

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

Remove saved data with key from the session storage.

Arguments

ArgumentTypeDefault value
keystrnull
frame_selectorstr, NoneNone
ArgumentsDescription
keyThe name of the item which shall be deleted.
frame_selectorIf this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

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

Save data to session storage.

Arguments

ArgumentTypeDefault value
keystrnull
valuestrnull
frame_selectorstr, NoneNone
ArgumentsDescription
keyThe name of the key under which it should be saved.
valueThe value which shall be saved as a string.
frame_selectorIf this selector points to an element inside an iframe, the SessionStorage of that frame is used. Example: iframe[name="test"] >>> body

Usage

SessionStorage Set Item key2 value2

Set keywords formatters for assertions.

Arguments

ArgumentTypeDefault value
formattersDict[str, List[str]]null

formatters is dictionary, where key is the keyword name where formatters are applied. Dictionary value is a list of formatter which are applied. Using keywords always replaces existing formatters for keywords.

Supported formatter are: normalize space, strip and apply to expected.

Usage

Set Assertion Formatters {"Get Text": ["strip", "normalize spaces"]} ${value} = Get Text //div == ${SPACE}Expected${SPACE * 2}Text Should Be Equal ${value} Expected Text

Sets the timeout used by most input and getter keywords.

Arguments

ArgumentTypeDefault value
timeouttimedeltanull
scopeScopeSuite
ArgumentsDescription
timeoutTimeout of it is for current playwright context and for new contexts. Supports Robot Framework time format . Returns the previous value of the timeout.
scopeScope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope Settings for more details.

Usage

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

Set default runBeforeUnload value when Close Page is called indirectly.

Arguments

ArgumentTypeDefault value
runBeforeUnloadboolnull

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.

Updated the correct Context's geolocation.

Arguments

ArgumentTypeDefault value
latitudefloatnull
longitudefloatnull
accuracyfloat, NoneNone

Latitude can be between -90 and 90 and longitude can be between -180 and 180. Accuracy of the location must be positive number and defaults to 0. When creating context, grant geolocation permission for pages to read its geolocation.

ArgumentsDescription
latitudeLatitude between -90 and 90.
longitudeLongitude between -180 and 180.
accuracyNon-negative accuracy value. Defaults to 0.

Usage

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

Toggles current Context's offline emulation.

Arguments

ArgumentTypeDefault value
offlineboolTrue
ArgumentsDescription
offlineToggles the offline mode. Set to False to switch back to online mode. Defaults to True.

Sets the timeout used in retrying assertions when they fail.

Arguments

ArgumentTypeDefault value
timeouttimedeltanull
scopeScopeSuite
ArgumentsDescription
timeoutAssertion retry timeout will determine how long Browser library will retry an assertion to be true.
scopeScope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope for more details.

The other keyword Set Browser timeout controls how long Playwright will perform waiting in the node side for Elements to fulfill the requirements of the specific keyword.

Returns the previous value of the assertion retry timeout.

Usage

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

Example waits 10 seconds on Playwright to get the page title and library will retry 30 seconds to make sure that title is correct.

Sets the prefix for all selectors in the given scope.

Arguments

ArgumentTypeDefault value
prefixstr, Nonenull
scopeScopeSuite
ArgumentsDescription
prefixPrefix for all selectors. Prefix and selector will be separated by a single space.
scopeScope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope for more details.

Returns the previous value of the prefix.

Usage

${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.

Controls library strict mode.

Arguments

ArgumentTypeDefault value
modeboolnull
scopeScopeSuite
ArgumentsDescription
modeWhen set to True, keywords that are searching elements will use Playwright strict mode. Keyword changes library strict mode value and keyword also return the previous strict mode value.
scopeScope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope for more details.

Usage

${old_mode} = Set Strict Mode False Get Text //input # Does not fail if selector points to one or more elements Set Strict Mode ${old_mode}

Sets current Pages viewport size to specified dimensions.

Arguments

ArgumentTypeDefault value
widthintnull
heightintnull

In the case of multiple pages in a single browser, each page can have its own viewport size. However, New Context allows to set 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 before navigating to the page with New Context before opening the page itself.

ArgumentsDescription
widthSets the width size.
heightSets the height size.

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

Arguments

ArgumentTypeDefault value
showboolTrue
stylestr
scopeScopeSuite

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

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

ArgumentsDescription
showIf True banner is shown on page. If False banner is not shown on page. If None banner is shown on page only when running in presenter mode.
styleAdditional css styles to be applied to the banner. These styles are css settings and may override the existing ones for the banner.
scopeScope defines the live time of that setting. Available values are Global, Suite or Test / Task. See Scope for more details.

Usage

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

Switches the currently active Browser to another open Browser.

Arguments

ArgumentTypeDefault value
idstrnull

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

ArgumentsDescription
idThe id of the browser to switch to. Example: browser=96207191-8147-44e7-b9ac-5e04f2709c1d. A browser id is returned by New Browser when it is started or can be fetched from the browser catalog when returned by Get Browser Catalog.

Switches the active BrowserContext to another open context.

Arguments

ArgumentTypeDefault value
idstrnull
browserSelectionType, strCURRENT

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

ArgumentsDescription
idThe id of the context to switch to. Example: context=525d8e5b-3c4e-4baa-bfd4-dfdbc6e86089. A context id is returned by New Context when it is started or can be fetched from the browser catalog when returned by Get Browser Catalog.
browserThe browser in which to search for that context. CURRENT for the currently active browser, ALL to search in all open browsers or the id of the browser where to switch context.

Usage

${first_context} = New Context New Page ${URL1} ${second_context} = New Context New Page ${URL2} Switch Context ${first_context} # Switches back to first context and page.

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

Arguments

ArgumentTypeDefault value
idNewPageDetails, strnull
contextSelectionType, strCURRENT
browserSelectionType, strCURRENT

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

ArgumentsDescription
idThe 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.
contextThe 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.
browserThe 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.

New may timeout if no new pages exists before library timeout.

Usage

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

DEPRECATED Use Tap instead.

Arguments

ArgumentTypeDefault value
selectorstrnull
forceboolFalse
noWaitAfterboolFalse
position_xint, NoneNone
position_yint, NoneNone
trialboolFalse
modifiersKeyboardModifiernull

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

Arguments

ArgumentTypeDefault value
filenamestr, Nonerobotframework-browser-screenshot-{index}
selectorstr, NoneNone
null
cropBoundingBox, NoneNone
disableAnimationsboolFalse
fileTypeScreenshotFileTypespng
fullPageboolFalse
log_screenshotboolTrue
maskList[str], str
maskColorstr, NoneNone
omitBackgroundboolFalse
qualityint, NoneNone
scaleScale, NoneNone
return_asScreenshotReturnTypepath_string
timeouttimedelta, NoneNone
ArgumentsDescription
filenameFilename 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 custom path or filename. String {index} in filename will be replaced with a rolling number. Use this to not override filenames. If filename equals to EMBED (case insensitive) or ${NONE}, then screenshot is embedded as Base64 image to the log.html. The image is saved temporally to the disk and warning is displayed if removing the temporary file fails. The ${OUTPUTDIR}/browser/ is removed at the first suite startup.
selectorTake 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 current viewport.
cropCrops the taken screenshot to the given box. It takes same dictionary as returned from Get BoundingBox. Cropping only works on page screenshot, so if no selector is given.
disableAnimationsWhen 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 transitionend event. - infinite animations are canceled to initial state, and then played over after the screenshot.
fileTypepng or jpeg Specify screenshot type, defaults to png .
fullPageWhen True, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to False.
log_screenshotWhen set to False the screenshot is taken but not logged into log.html.
maskSpecify selectors that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box #FF00FF that completely covers its bounding box. Argument can take a single selector string or a list of selector strings if multiple different elements should be masked.
maskColorSpecify the color of the overlay box for masked elements, in CSS color format. Default color is pink #FF00FF.
omitBackgroundHides default white background and allows capturing screenshots with transparency. Not applicable to jpeg images.
qualityThe quality of the image, between 0-100. Not applicable to png images.
scalecss or device. css will reduce the image size and device keeps image in original size. Defaults to device.
return_asDefines 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.
timeoutMaximum time how long taking screenshot can last, defaults to library timeout. Supports Robot Framework time format, like 10s or 1 min, pass 0 to disable timeout. The default value can be changed by using the Set Browser Timeout keyword.

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 Take Screenshot fullPage=True fileType=jpeg quality=50 timeout=10s Take Screenshot EMBED # Screenshot is embedded as Base64 image to the log.html.

Simulates tap on the element found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
modifiersKeyboardModifiernull
forceboolFalse
noWaitAfterboolFalse
position_xint, NoneNone
position_yint, NoneNone
trialboolFalse

Requires that the hasTouch option of the New Context be set to true. This method taps the element by performing the following steps:

  • Wait for actionability checks on the element, unless force option is set.
  • Scroll the element into view if needed.
  • Use page.touchscreen to tap the center of the element, or the specified position.
  • Wait for initiated navigations to either succeed or fail, unless noWaitAfter option is set.
ArgumentsDescription
selectorSelector element to click. See the Finding elements section for details about the selectors.
*modifiersModifier 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 Control, Alt, Shift and Meta.
forceWhether to bypass the actionability checks. Defaults to false.
noWaitAfterActions that initiate navigations are waiting for these navigations 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 position_yA point to click relative to the top-left corner of element bounding-box. Only positive values within the bounding-box are allowed. If not specified, clicks to some visible point of the element.
trialWhen set, this method only performs the actionability checks and skips the action. Defaults to False.

Usage

New Context hasTouch=${False} New Page ${URL} Tap css=input#login_button

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

Arguments

ArgumentTypeDefault value
selectorstrnull
secretstrnull
delaytimedelta0:00:00
clearboolTrue

This keyword does not log secret in Robot Framework logs, if keyword resolves the variable value internally. If enable_playwright_debug is enabled in the library import, secret will be always visible as plain text in the playwright debug logs, regardless of the Robot Framework log level.

ArgumentsDescription
selectorSelector of the text field. See the Finding elements section for details about the selectors.
secretEnvironment variable name with % prefix or a local variable with $ prefix that has the secret text value. Variable names can be used with and without curly braces.
delayDelay 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
clearSet to false, if the field shall not be cleared before typing. Defaults to true.

This keyword does not log secret in Robot Framework logs, when keyword resolves the secret variable internally. When secret variable is prefixed with $, without the curly braces, library will resolve the corresponding Robot Framework variable.

If secret variable is prefixed with %, library will resolve corresponding environment variable. Example $Password` will resolve to ${Password} Robot Framework variable. Also %ENV_PWD will resolve to %{ENV_PWD} environment variable.

Using normal Robot Framework variables like ${password} will not work!

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

This keyword will also work with a give cryptographic cipher text, that has been encrypted by Crypto library. See Crypto Library 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 variables Type Secret input#username_field %username # Keyword resolves $USERNAME/%USERNAME% variable value from environment variables Type Secret input#username_field ${username} # Robot Framework resolves the variable value, but secrect can leak to Robot framework output files.

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

Arguments

ArgumentTypeDefault value
selectorstrnull
txtstrnull
delaytimedelta0:00:00
clearboolTrue

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

ArgumentsDescription
selectorSelector of the text field. See the Finding elements section for details about the selectors.
txtText for the text field.
delayDelay 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
clearSet to false, if the field shall not be cleared before typing. Defaults to true.

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

See Fill Text for direct filling of the full text at once.

Example

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

Unchecks the checkbox found by selector.

Arguments

ArgumentTypeDefault value
selectorstrnull
forceboolFalse
ArgumentsDescription
selectorSelector of the checkbox. See the Finding elements section for details about the selectors.
forceSet to True to skip Playwright's [https://playwright.dev/docs/actionabilityActionability checks].

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

Does nothing if the element is not checked/selected.

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

Arguments

ArgumentTypeDefault value
selectorstrnull
pathPathLikenull

Fails if upload is not done before library timeout. Therefor it may be necessary to increase the timeout with Set Browser Timeout.

ArgumentsDescription
selectorIdentifies the file input element.
pathPath to the file to be uploaded.

Usage

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

Waits for promises to finish and returns results from them.

Arguments

ArgumentTypeDefault value
promisesFuturenull

Returns one result if one promise waited. Otherwise returns an array of results. If one fails, then this keyword will fail.

See Promise To for more information about promises.

For general waiting of elements please see Implicit waiting.

ArgumentsDescription
promisesPromises to wait for.

Usage

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

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

Arguments

ArgumentTypeDefault value
actionDialogActionnull
prompt_inputstr
textstr, NoneNone

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

ArgumentsDescription
actionHow to handle the alert. Can be accept or dismiss.
prompt_inputThe value to enter into prompt. Only valid if action argument equals accept. Defaults to empty string.
textOptional text to verify the dialogs text.

The main difference between this keyword and Handle Future Dialogs is that Handle Future Dialogs keyword is automatically set as promise. But this keyword must be called as argument to Promise To keyword. Also this keyword can optionally verify the dialogue text and return it. If text is argument None or is not set, dialogue 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 verify:

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

Waits for all promises to finish.

If one promises fails, then this keyword will fail.

Usage

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

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

Arguments

ArgumentTypeDefault value
conditionConditionInputsnull
argsAnynull
timeouttimedelta, NoneNone
messagestr, NoneNone

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 Frameworks Wait Until Keywords Succeeds this keyword is more readable and easier to use but is limited to Browser libraries assertion keywords.

ArgumentsDescription
conditionA condition, defined with Browser getter keywords, without the word Get.
*argsArguments to pass to the condition keyword.
timeoutTimout to wait for the condition to become True. Uses default timeout of the library if not set.
messageOverrides the default error message.

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

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

Arguments

ArgumentTypeDefault value
selectorstrnull
stateElementStatevisible
timeouttimedelta, NoneNone
messagestr, NoneNone

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

State options could be either appear/disappear from dom, or become visible/hidden. 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.

ArgumentsDescription
selectorSelector of the corresponding object. See the Finding elements section for details about the selectors.
stateSee ElementState for explanation.
timeoutuses default timeout from library if not set.
messageoverrides the default error message. The message argument accepts {selector}, {function}, and {timeout} format options. The {function} formatter is same state argument value.

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

Usage

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

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

Arguments

ArgumentTypeDefault value
functionstrnull
selectorstr
pollingstr, timedeltaraf
timeouttimedelta, NoneNone
messagestr, NoneNone
ArgumentsDescription
functionA valid javascript function or a javascript function body. For example () => true and true will behave similarly.
selectorSelector to resolve and pass to the JavaScript function. This will be the first argument the function receives. If given a selector a function is necessary, with an argument to capture the elementhandle. For example (element) => document.activeElement === element See the Finding elements section for details about the selectors.
pollingDefault polling value of "raf" polls in a callback for requestAnimationFrame. Any other value for polling will be parsed as a robot framework time for interval between polls.
timeoutUses default timeout of the library if not set.
messageoverrides the default error message. The message argument accepts {selector}, {function}, and {timeout} format options.

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}

Waits until page has navigated to given url.

Arguments

ArgumentTypeDefault value
urlstr, RegExpnull
timeouttimedelta, NoneNone
wait_untilPageLoadStatesload
ArgumentsDescription
urlExpected navigation target address either the exact match or a JavaScript-like regex wrapped in / symbols.
timeoutTimeout supports Robot Framework time format. Uses default timeout if not set.
wait_untilWhen to consider 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.

Keyword works only when page is loaded and does not work if 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 keyword will fail.

Usage

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

Waits for request matching matcher to be made.

Arguments

ArgumentTypeDefault value
matcherstr, RegExp
timeouttimedelta, NoneNone
ArgumentsDescription
matcherRequest URL matcher. Can be a string (Glob-Pattern), JavaScript RegExp (encapsulated in / with following flags) or JavaScript arrow-function that receives the Request object and returns a boolean. By default (with empty string) matches first available request. For additional information, see the Playwright waitForRequest documentation.
timeoutTimeout supports Robot Framework time format. Uses default timeout if not set.

See Wait For Response for more details.

CAUTION: Before Browser library 17.0.0, the matcher argument was always either a regex or JS function. But the regex did not needed 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/.

Waits for response matching matcher and returns the response as robot dict.

Arguments

ArgumentTypeDefault value
matcherstr, RegExp
timeouttimedelta, NoneNone

The response, which is returned by this keyword, is a robot dictionary with following attributes:

  • status <int> The status code of the response.
  • statusText <str> Status text corresponding to status, e.g OK or INTERNAL SERVER ERROR.
  • 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 range 200-299.
  • request <dict> containing method <str>, headers <dict> and postData <dict> | <str>
  • url <str> url of the request.
ArgumentsDescription
matcherRequest URL matcher. Can be a string (Glob-Pattern), JavaScript RegExp (encapsulated in / with following flags) or JavaScript arrow-function that receives the Response object and returns a boolean. By default (with empty string) matches first available request. For additional information, see the Playwright page.waitForResponse documentation.
timeoutTimeout supports Robot Framework time format. Uses default timeout if not set.

CAUTION: Before Browser library 17.0.0, the matcher argument was always either a regex or JS function. But the regex did not needed 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/.

Matcher Examples:

Glob-Pattern:

Glob-Patterns are strings that can contain wildcards. The following wildcards are supported:

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)

Usage

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

RegExp:

Regular Expressions are JavaScript regular expressions encapsulated in / with optional following 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 request 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-Function:

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

Robot Examples:

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'

Waits until there has been at least one instance of 500 ms of no network traffic on the page after loading.

Arguments

ArgumentTypeDefault value
timeouttimedelta, NoneNone

Doesn't wait for network traffic that wasn't initiated within 500ms of page load.

ArgumentsDescription
timeoutTimeout supports Robot Framework time format. Uses browser timeout if not set.

Usage

Go To ${URL} Wait Until Network Is Idle timeout=3s