Add Style Tag

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

Arguments

Argument Type Default value Description
contentstrnull

content Raw CSS content to be injected into frame.

Check Checkbox

Checks the checkbox or selects radio button found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull

Checks the checkbox or selects radio button found by selector.

selector Selector of the checkbox. See the Finding elements section for details about the selectors.

Does nothing if the element is already checked/selected.

Clear Text

Clears the text field found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull

Clears the text field found by selector.

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

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

Click

Simulates mouse click on the element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
buttonMouseButtonleft
clickCountint1
delaytimedeltaNone
position_xfloatNone
position_yfloatNone
forceboolFalse
noWaitAfterboolFalse
modifiersKeyboardModifiernull

Simulates mouse click on the element found by selector.

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.

selector Selector element to click. See the Finding elements section for details about the selectors.

button Defaults to left if invalid.

click_count Defaults to 1.

delay Time to wait between mouse-down and mouse-up. Defaults to 0.

position_x & position_y A 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.

force Set to True to skip Playwright's Actionability checks.

noWaitAfter Actions that initiate navigation, are waiting for these navigation to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to False.

*modifiers Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.

Close Browser

Closes the current browser. Activated browser is set to first active browser. Closes all context and pages belonging to this browser. See `Browser, Context and Page` for more information about Browser and related concepts.

Arguments

Argument Type Default value Description
browserstrCURRENT

Closes the current browser. Activated browser is set to first active browser. Closes all context and pages belonging to this browser. See Browser, Context and Page for more information about Browser and related concepts.

browser < CURRENT | ALL | str > If value is not CURRENT it should be a string referencing the id of the browser to be closed. If ALL is provided Close All Browsers is executed.

Close Context

Closes a Context. Activated context is set to first active context. Closes pages belonging to this context. See `Browser, Context and Page` for more information about Context and related concepts.

Arguments

Argument Type Default value Description
contextstrCURRENT
browserstrCURRENT

Closes a Context. Activated context is set to first active context. Closes pages belonging to this context. See Browser, Context and Page for more information about Context and related concepts.

context < CURRENT | ALL | str > Close context with specified id. If ALL is passed, all contexts of the specified browser are closed. Defaults to CURRENT.

browser < CURRENT | ALL | str > Close context in specified browser. If value is not "CURRENT" it should be a string referencing the id of the browser where to close context.

Close Page

Closes the ``page`` in ``context`` in ``browser``. Defaults to current for all three. Activated page is set to first active page. See `Browser, Context and Page` for more information about Page and related concepts.

Arguments

Argument Type Default value Description
pagestrCURRENT
contextstrCURRENT
browserstrCURRENT

Closes the page in context in browser. Defaults to current for all three. Activated page is set to first active page. See Browser, Context and Page for more information about Page and related concepts.

page < CURRENT | ALL | str > Id of the page to close. If value is not "CURRENT" it should be a string referencing the id of the context where to close page. If ALL is passed, all pages of the given context are closed. Defaults to CURRENT.

context < CURRENT | ALL | str > Id of the context that belongs to the page to be closed. If ALL is passed, the requested pages of all contexts are closed. Defaults to CURRENT.

browser < CURRENT | ALL | str > Id of the browser that belongs to the page to be closed. If ALL is passed, the requested pages depending of the context of all browsers are closed. Defaults to CURRENT.

Connect To Browser

Connect to a playwright Browser. See `Browser, Context and Page` for more information about Browser and related concepts.

Arguments

Argument Type Default value Description
wsEndpointstrnull
browserSupportedBrowserschromium

Connect to a playwright Browser. See Browser, Context and Page for more information about Browser and related concepts.

Returns a stable identifier for the connected browser.

wsEndpoint Address to connect to.

browser Opens the specified browser. Defaults to chromium.

Delete All Cookies

Deletes all cookies from the currently active browser context.

Deselect Options

Deselects all options from select element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull

Deselects all options from select element found by selector.

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

Download

Download given url content and return downloaded file path

Arguments

Argument Type Default value Description
urlstrnull

Drag And Drop

Executes a Drag&Drop operation from the element selected by ``selector_from`` to the element selected by ``selector_to``. See the `Finding elements` section for details about the selectors.

Arguments

Argument Type Default value Description
selector_fromstrnull
selector_tostrnull
stepsint1

Executes a Drag&Drop operation from the element selected by selector_from to the element selected by selector_to. See the Finding elements section for details about the selectors.

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

Start- and end-point are defined by the center of the elements boundingbox.

selector_from identifies the element, which center is the start-point.

selector_to identifies the element, which center is the end-point.

steps defines how many intermediate mouse move events are sent.

Drag And Drop By Coordinates

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

Arguments

Argument Type Default value Description
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_y identify the the start-point.

to_x & to_y identify the the end-point.

steps defines how many intermediate mouse move events are sent.

Eat All Cookies

Eat all cookies for all easter.

Execute JavaScript

Executes given javascript on the page.

Arguments

Argument Type Default value Description
functionstrnull
selectorstr

function A valid javascript function or a javascript function body. For example () => true and true will behave similarly.

selector Selector 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.

Usage examples.

Fill Secret

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

Arguments

Argument Type Default value Description
selectorstrnull
secretstrnull

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

This keyword does not log secret in Robot Framework logs. 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.

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

secret Environment 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.

Example: $Password and ${Password} resolve the robot framework variable. %ENV_PWD and %{ENV_PWD} resolve to the environment variable ENV_PWD.

See Fill Text for other details.

Fill Text

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

Arguments

Argument Type Default value Description
selectorstrnull
textstrnull

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

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 text to clear the input field.

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

text Text for the text field.

See Type Text for emulating typing text character by character.

Focus

Moves focus on to the element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull

Moves focus on to the element found by selector.

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

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

Get Attribute

Returns the HTML ``attribute`` of the element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
attributestrnull
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Returns the HTML attribute of the element found by selector.

Optionally asserts that the attribute value matches the specified assertion.

selector Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.

attribute Requested attribute name.

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.

message overrides the default error message.

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

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

Get Attribute Names

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

Arguments

Argument Type Default value Description
selectorstrnull
assertion_operatorAssertionOperatorNone
assertion_expectednull
messagestr, NoneNone

Optionally asserts that these match the specified assertion.

selector Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.

assertion_operator See Assertions for further details. Defaults to None.

Available assertions:

  • == and != can work with multiple values
  • contains / *= only accepts one single expected value

Other operators are not allowed.

message overrides the default error message.

Get BoundingBox

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

Arguments

Argument Type Default value Description
selectorstrnull
keyBoundingBoxFieldsALL
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

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

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

key Optionally filters the returned values. If keys is set to ALL (default) it will return the BoundingBox as Dictionary, otherwise it will just return the single value selected by the key. Note: If a single value is retrieved, an assertion does not need a validate combined with a cast of value.

message overrides the default error message.

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

Example use:

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

Get Browser Catalog

Returns all browsers, open contexts in them and open pages in these contexts. See `Browser, Context and Page` for more information about these concepts.

Arguments

Argument Type Default value Description
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Returns all browsers, open contexts in them and open pages in these contexts. See Browser, Context and Page for more information about these concepts.

message overrides the default error message.

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
  }
]

Get Browser Ids

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

Arguments

Argument Type Default value Description
browserSelectionTypeALL

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

browser Defaults to ALL

  • ALL / ANY Returns all ids as a list.
  • ACTIVE / CURRENT Returns the id of the currently active browser as list.

The ACTIVE browser is a synonym for the CURRENT Browser.

Get Checkbox State

Returns the state of the checkbox found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
assertion_operatorAssertionOperatorNone
expected_statebool, strUnchecked
messagestrNone

Returns the state of the checkbox found by selector.

selector Selector which shall be examined. See the Finding elements section for details about the selectors.

Optionally asserts that the state matches the specified assertion.

assertion_operator See Assertions for further details. Defaults to None.

  • == and != and equivalent are allowed on boolean values
  • other operators are not accepted.

expected_state boolean 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

  • checked => True
  • unchecked => False

message overrides the default error message.

Get Classes

Returns all classes of an element as a list.

Arguments

Argument Type Default value Description
selectorstrnull
assertion_operatorAssertionOperatorNone
assertion_expectednull
messagestr, NoneNone

Optionally asserts that the value matches the specified assertion.

selector Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.

assertion_operator See Assertions for further details. Defaults to None.

Available assertions:

  • == and != can work with multiple values
  • contains / *= only accepts one single expected value

Other operators are not allowed.

Get Client Size

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

Arguments

Argument Type Default value Description
selectorstrNone
keySizeFieldsALL
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

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

selector Optional 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.

key Optionally filters the returned values. If keys is set to ALL (default) it will return the scroll size as dictionary, otherwise it will just return the single value selected by the key.

message overrides the default error message.

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

See Get BoundingBox or Get Scroll Size for examples.

Get Context Ids

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

Argument Type Default value Description
contextSelectionTypeALL
browserSelectionTypeALL

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

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

context Defaults to ALL

  • ALL Returns all context ids as a list.
  • ACTIVE Returns the id of the active context as a list.

browser Defaults to ALL

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

Get Cookies

Returns cookies from the current active browser context.

Arguments

Argument Type Default value Description
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 Device

Get a single device decriptor with name exactly matching name.

Arguments

Argument Type Default value Description
namestrnull

name Given name of the requested device. See Playwright's deviceDescriptors.ts 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 }

Get Devices

Returns a dict of all playwright device descriptors.

See Playwright's deviceDescriptors.ts for a formatted list.

Get Element

Returns a reference to a Playwright element handle.

Arguments

Argument Type Default value Description
selectorstrnull

The reference can be used in subsequent selectors.

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

Get Element Count

Returns the count of elements found with ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
assertion_operatorAssertionOperatorNone
expected_valueint, str0
messagestrNone

Returns the count of elements found with selector.

Optionally asserts that the count matches the specified assertion.

selector Selector which shall be counted. See the Finding elements section for details about the selectors.

assertion_operator See Assertions for further details. Defaults to None.

expected_value Expected value for the counting

message overrides the default error message.

Get Element State

Get the given state from the element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
stateElementStateKeyvisible
assertion_operatorAssertionOperatorNone
assertion_expectedboolTrue
messagestrNone

Get the given state from the element found by selector.

If the selector does satisfy the expected state it will return True otherwise False.

selector Selector of the corresponding object. See the Finding elements section for details about the selectors.

state Defaults to visible. Possible states are:

  • attached : to be present in DOM.
  • visible : to have non-empty bounding box and no visibility:hidden.
  • disabled : to be disabled. Can be used on <button>, <fieldset>, <input>, <optgroup>, <option>, <select> and <textarea>.
  • readonly : to be readOnly. Can be used on <input> and <textarea>.
  • selected : to be selected. Can be used on <option>.
  • focused : to be the activeElement.
  • checked : to be checked . Can be used on <input>.

Note that element must be attached to DOM to be able to fetch the state of readonly , selectec and checked. The other states are false if the requested element is not attached.

Note that element without any content or with display:none has an empty bounding box and is not considered visible.

message overrides the default error message.

Get Elements

Returns a reference to playwright element handle for all matched elements by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull

Returns a reference to playwright element handle for all matched elements by selector.

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

Get Page Ids

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

Argument Type Default value Description
pageSelectionTypeALL
contextSelectionTypeALL
browserSelectionTypeALL

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

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

page

  • ALL Returns all page ids as a list.
  • ACTIVE Returns the id of the active page as a list.

context

  • ALL page ids from all contexts shall be fetched.
  • ACTIVE only page ids from the active context shall be fetched.

browser

  • ALL page ids from all open browsers shall be fetched.
  • ACTIVE only page ids from the active browser shall be fetched.

Examples

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.

Get Page Source

Gets pages HTML source as a string.

Arguments

Argument Type Default value Description
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

message overrides the default error message.

Optionally does a string assertion.

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

Get Property

Returns the ``property`` of the element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
propertystrnull
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Returns the property of the element found by selector.

Optionally asserts that the property value matches the specified assertion.

selector Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.

property Requested property name.

If assertion_operator is set and property is not found, value is None and Keyword does not fail. See Get Attribute for examples.

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

message overrides the default error message.

Get Scroll Position

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

Arguments

Argument Type Default value Description
selectorstrNone
keyAreaFieldsALL
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

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

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

top uses js function scrollTop, left uses scrollLeft and bottom and right are calculated with the client size.

selector Optional 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.

key Optionally filters the returned values. If keys is set to ALL (default) it will return the scroll position as dictionary, otherwise it will just return the single value selected by the key.

message overrides the default error message.

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

See Get BoundingBox or Get Scroll Size for examples.

Get Scroll Size

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

Arguments

Argument Type Default value Description
selectorstrNone
keySizeFieldsALL
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

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

selector Optional 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.

key Optionally filters the returned values. If keys is set to ALL (default) it will return the scroll size as dictionary, otherwise it will just return the single value selected by the key.

message overrides the default error message.

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

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}

Get Selected Options

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

Arguments

Argument Type Default value Description
selectorstrnull
option_attributeSelectAttributelabel
assertion_operatorAssertionOperatorNone
assertion_expectednull

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

Optionally asserts that these match the specified assertion.

selector Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.

option_attribute Which attribute shall be returned/verified. Defaults to label.

assertion_operator See Assertions for further details. Defaults to None.

  • == and != can work with multiple values
  • contains / *= only accepts one single expected value

Other operators are not allowed.

Examples

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

Get Style

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

Arguments

Argument Type Default value Description
selectorstrnull
keystrALL
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

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

Optionally matches with any sequence assertion operator.

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

key Key of the requested CSS property. Retrieves "ALL" styles by default.

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

message overrides the default error message.

Get Text

Returns text attribute of the element found by ``selector``. See the `Finding elements` section for details about the selectors.

Arguments

Argument Type Default value Description
selectorstrnull
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone

Returns text attribute of the element found by selector. See the Finding elements section for details about the selectors.

Optionally asserts that the text matches the specified assertion.

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

Get Textfield Value

Returns value of the textfield found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Returns value of the textfield found by selector.

Optionally asserts that the value matches the specified assertion.

selector Selector from which the info is to be retrieved. See the Finding elements section for details about the selectors.

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

message overrides the default error message.

Get Title

Returns the title of the current page.

Arguments

Argument Type Default value Description
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Optionally asserts that it matches the specified assertion.

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

message overrides the default error message.

Get Url

Returns the current URL.

Arguments

Argument Type Default value Description
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Optionally asserts that it matches the specified assertion.

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

message overrides the default error message.

Get Viewport Size

Returns the current viewport dimensions.

Arguments

Argument Type Default value Description
keySizeFieldsALL
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

Optionally asserts that the count matches the specified assertion.

key Optionally filters the returned values. If keys is set to ALL (default) it will return the viewport size as dictionary, otherwise it will just return the single value selected by the key. Note: If a single value is retrieved, an assertion does not need a validate combined with a cast of value.

message overrides the default error message.

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

Examples

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

Go Back

Navigates to the previous page in history.

Go Forward

Navigates to the next page in history.

Go To

Navigates to the given ``url``.

Arguments

Argument Type Default value Description
urlstrnull
timeouttimedeltaNone

Navigates to the given url.

url <str> URL to be navigated to. timeout <str> time to wait page to load. If not defined will use the the library default timeout.

Handle Future Dialogs

Handle next dialog on page with ``action``. Dialog can be any of alert, beforeunload, confirm or prompt.

Arguments

Argument Type Default value Description
actionDialogActionnull
prompt_inputstr

Handle next dialog on page with action. Dialog can be any of alert, beforeunload, confirm or prompt.

action How to handle the alert.

prompt_input The value to enter into prompt. Only valid if action equals accept. Defaults to empty string.

Highlight Elements

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

Arguments

Argument Type Default value Description
selectorstrnull
durationtimedelta0:00:05
widthstr2px
stylestrdotted
colorstrblue

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

selector Selectors which shall be highlighted. See the Finding elements section for details about the selectors.

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

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

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

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

Hover

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

Arguments

Argument Type Default value Description
selectorstrnull
position_xfloatNone
position_yfloatNone
forceboolFalse
modifiersKeyboardModifiernull

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

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

  • Find an element 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.

selector Selector element to hover. See the Finding elements section for details about the selectors.

position_x & position_y A point to hover relative to the top-left corner of element bounding box. If not specified, hovers over some visible point of the element. Only positive values within the bounding-box are allowed.

force Set to True to skip Playwright's Actionability checks.

*modifiers Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.

Http

Performs an HTTP request in the current browser context

Arguments

Argument Type Default value Description
urlstrnull
methodRequestMethodGET
bodystrNone
headersdictNone

Accepts the following arguments:

  • url The request url, e.g. /api/foo.
  • method The HTTP method for the request. Defaults to GET.
  • body The 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.
  • headers A 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

Keyboard Input

Input text into page with virtual keyboard.

Arguments

Argument Type Default value Description
actionKeyboardInputActionnull
inputstrnull
delay0

action

  • insertText Dispatches only input event, does not emit the keydown, keyup or keypress events.
  • type Sends a keydown, keypress/input, and keyup event for each character in the text.

input The inputstring to be typed. No special keys possible.

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

Keyboard Key

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

Arguments

Argument Type Default value Description
actionKeyActionnull
keystrnull

action Determine whether the key should be released, hold or pressed. down or up are useful for combinations i.e. with Shift.

key The 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.

LocalStorage Clear

Remove all saved data from the local storage.

LocalStorage Get Item

Get saved data from the local storage.

Arguments

Argument Type Default value Description
keystrnull
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone
messagestrNone

key Named key of the item in the storage.

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

LocalStorage Remove Item

Remove saved data with key from the local storage.

Arguments

Argument Type Default value Description
keystrnull

key Name of the item which shall be deleted.

LocalStorage Set Item

Save data to the local storage.

Arguments

Argument Type Default value Description
keystrnull
valuestrnull

key The name of the key under which it should be saved.

value The value which shall be saved as a string.

Mouse Button

Clicks, presses or releases a mouse button.

Arguments

Argument Type Default value Description
actionMouseButtonActionnull
xfloatNone
yfloatNone
buttonMouseButtonleft
clickCountint1
delayint0

action Determines if it is a mouseclick, holding down a key or releasing it.

x and y Coordinates to move before.

button Defaults to left.

clickCount Determine how often shall be clicked. Defaults to 1.

delay Delay in ms between the mousedown and mouseup event. Can only be set if the action is click.

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

Mouse Move

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

Arguments

Argument Type Default value Description
xfloatnull
yfloatnull
stepsint1

x y are absolute coordinates starting at the top left of the page.

steps Number of intermediate steps for the mouse event.

Mouse Move Relative To

Moves the mouse cursor relative to the selected element.

Arguments

Argument Type Default value Description
selectorstrnull
xfloat0.0
yfloat0.0
stepsint1

x y are relative coordinates to the center of the elements bounding box.

steps Number of intermediate steps for the mouse event. This is sometime needed for websites to recognize the movement.

New Browser

Create a new playwright Browser with specified options. See `Browser, Context and Page` for more information about Browser and related concepts.

Arguments

Argument Type Default value Description
browserSupportedBrowserschromium
headlessboolTrue
executablePathstrNone
argsList[str]None
ignoreDefaultArgsList[str]None
proxyProxyNone
downloadsPathstrNone
handleSIGINTboolTrue
handleSIGTERMboolTrue
handleSIGHUPboolTrue
timeouttimedelta0:00:30
envDictNone
devtoolsboolFalse
slowMotimedelta0:00:00

Create a new playwright Browser with specified options. See Browser, Context and Page for more information about Browser and related concepts.

Returns a stable identifier for the created browser.

browser Opens the specified browser. Defaults to chromium.

headless Set to False if you want a GUI. Defaults to False.

executablePath Path 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.

args Additional arguments to pass to the browser instance. The list of Chromium flags can be found here. Defaults to None.

ignoreDefaultArgs If an array is given, then filters out the given default arguments. Defaults to None.

proxy Network proxy settings.

  • server <string> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example http://myproxy.com:3128 or socks5://myproxy.com:3128. Short form myproxy.com:3128 is considered an HTTP proxy.
  • bypass <string> Optional coma-separated domains to bypass proxy, for example ".com, chromium.org, .domain.com".
  • username <string> Optional username to use if HTTP proxy requires authentication.
  • password <string> Optional password to use if HTTP proxy requires authentication.

downloadsPath If specified, accepted downloads are downloaded into this folder. Otherwise, temporary folder is created and is deleted when browser is closed.

handleSIGINT Close the browser process on Ctrl-C. Defaults to True.

handleSIGTERM Close the browser process on SIGTERM. Defaults to True.

handleSIGHUP Close the browser process on SIGHUP. Defaults to True.

timeout Maximum time in milliseconds to wait for the browser instance to start. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.

env <Dict<str, str|int|bool>> Specify environment variables that will be visible to the browser. Defaults to None.

devtools Chromium-only Whether to auto-open a Developer Tools panel for each tab. If this option is true, the headless option will be set false.

slowMo Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to no delay.

New Context

Create a new BrowserContext with specified options. See `Browser, Context and Page` for more information about BrowserContext.

Arguments

Argument Type Default value Description
acceptDownloadsboolFalse
ignoreHTTPSErrorsboolFalse
bypassCSPboolFalse
viewportViewportDimensionsNone
userAgentstrNone
deviceScaleFactorfloat1.0
isMobileboolFalse
hasTouchboolFalse
javaScriptEnabledboolTrue
timezoneIdstrNone
geolocationGeoLocationNone
localestrNone
permissionsList[str]None
extraHTTPHeadersDict[str, str]None
offlineboolFalse
httpCredentialsHttpCredentialsNone
colorSchemeColorSchemeNone
proxyProxyNone
videosPathstrNone
videoSizeViewportDimensionsNone
defaultBrowserTypeSupportedBrowsersNone
hideRfBrowserboolFalse
recordVideostrNone

Create a new BrowserContext with specified options. 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.

acceptDownloads Whether to automatically downloads all the attachments. Defaults to False where all the downloads are canceled.

ignoreHTTPSErrors Whether to ignore HTTPS errors during navigation. Defaults to False.

bypassCSP Toggles bypassing page's Content-Security-Policy. Defaults to False.

viewport Sets a consistent viewport for each page. Defaults to an {'width': 1280, 'height': 720} viewport. Value of viewport can be a dict or a string representation of a dictionary.

userAgent Specific user agent to use in this context.

deviceScaleFactor Specify device scale factor (can be thought of as dpr). Defaults to 1.

isMobile Whether the meta viewport tag is taken into account and touch events are enabled. Defaults to False. Not supported in Firefox.

hasTouch Specifies if viewport supports touch events. Defaults to False.

javaScriptEnabled Whether or not to enable JavaScript in the context. Defaults to True.

timezoneId Changes the timezone of the context. See ICU’s metaZones.txt for a list of supported timezone IDs.

geolocation Sets the geolocation. No location is set by default.

  • latitude <number> Latitude between -90 and 90.
  • longitude <number> Longitude between -180 and 180.
  • accuracy Optional <number> Non-negative accuracy value. Defaults to 0.

Example usage: {'latitude': 59.95, 'longitude': 30.31667}

locale Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules.

permissions A list of permissions to grant to all pages in this context. See grantPermissions for more details.

extraHTTPHeaders A dictionary containing additional HTTP headers to be sent with every request. All header values must be strings.

offline Whether to emulate network being offline. Defaults to False.

httpCredentials Credentials for HTTP authentication.

  • example: {'username': 'admin', 'password': '123456'}
  • username
  • password

colorScheme Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference'. See emulateMedia(options) for more details. Defaults to light.

proxy Network proxy settings to use with this context. Note that 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

videosPath is deprecated by playwright, use recordVideo instead. Enables video recording for all pages to videosPath folder. If videosPath is not existing folder, videosPath folder is created under ${OUTPUT_DIR}/browser/video/ folder. If videosPath is not specified, videos are not recorded.

videoSize is deprecated by playwright, use recordVideo instead. Specifies dimensions of the automatically recorded video. Can only be used if videosPath is set. If not specified the size will be equal to viewport. If viewport is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.

  • Example {"width": 1280, "height": 720}

defaultBrowserType If 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:

recordVideo enables 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. recordVideo is dictionary containing dir and size keys. If dir is not existing folder, videosPath folder is created under ${OUTPUT_DIR}/browser/video/ folder. size Optional dimensions of the recorded videos. If not specified the size will be equal to viewport. If viewport is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size. size is dictionary containing width (Video frame width) and height (Video frame height) keys.

Examples

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.

New Page

Open a new Page. A Page is the Playwright equivalent to a tab. See `Browser, Context and Page` for more information about Page concept. Returns a stable identifier for the created page.

Arguments

Argument Type Default value Description
urlstrNone

Open a new Page. A Page is the Playwright equivalent to a tab. See Browser, Context and Page for more information about Page concept. Returns a stable identifier for the created page.

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

url If specified it will open the new page to the specified URL.

Open Browser

Opens a new browser instance. Use this keyword for quick experiments or debugging sessions. 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.

Arguments

Argument Type Default value Description
urlstrNone
browserSupportedBrowserschromium
headlessboolFalse
pause_on_failureboolTrue

Opens a new browser instance. Use this keyword for quick experiments or debugging sessions. 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. Only supports some of the settings Create _ Keywords do

url Navigates to URL if provided. Defaults to None.

browser Specifies which browser to use. The supported browsers are listed in the table below. The browser names are case-sensitive.

Value Name(s)
firefox Firefox
chromium Chromium
webkit webkit

headless If set to False, a GUI is provided otherwise it is hidden. Defaults to False.

pause_on_failure Stop execution when failure detected and leave browser open. Defaults to True.

Press Keys

Types the given key combination into element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
keysstrnull

Types the given key combination into element found by selector.

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

Supports values like "a, b" which will be automatically typed. . Also supports identifiers for keys like ArrowLeft or Backspace. Using + to chain combine modifiers with a single keypress Control+Shift+T is supported.

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

Examples

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

Promise To

Wrap a Browser library keyword and make it a promise. Returns that promise and executes the keyword on background.

Arguments

Argument Type Default value Description
kwstrnull
argsnull

kw Keyword that will work async on background.

Examples

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

Register Keyword To Run On Failure

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

Arguments

Argument Type Default value Description
keywordstr, Nonenull

keyword is the name of a keyword that will be executed if a Browser keyword fails. It is possible to use any available keyword, including user keywords or keywords from other libraries, but the keyword must not take any arguments.

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 the name of the previously registered failure keyword or Python None if this functionality was previously disabled. The return value can be always used to restore the original value later.

Examples

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}

Reload

Reloads current active page.

Scroll By

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

Arguments

Argument Type Default value Description
selectorstrNone
verticalstrheight
horizontalstr0
behaviorScrollBehaviorauto

selector Selector of the element. If the selector is ${None} or ${Empty} the page itself is scrolled. To ensure an element is in view use Hover instead. See the Finding elements section for details about the selectors.

vertical defines how far and in which direction to scroll vertically. It can be a positive or negative number. Positive scrolls down, like 50, negative scrolls up, like -50. It can be a percentage value of the absolute scrollable size, like 9.95% or negative like -10%. It can be the string height to 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.

horizontal defines 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.

behavior defines whether the scroll happens directly or it scrolls smoothly.

Scroll To

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

Arguments

Argument Type Default value Description
selectorstrNone
verticalstrtop
horizontalstrleft
behaviorScrollBehaviorauto

selector Selector of the element. If the selector is ${None} or ${Empty} the page itself is scrolled. To ensure an element is in view use Hover instead. See the Finding elements section for details about the selectors.

vertical defines where to scroll vertically. It can be a positive number, like 300. It can be a percentage value of the absolute scrollable size, like 50%. It can be a string defining that top or the bottom of the scroll area. < top | bottom > Be aware that some pages do lazy loading and load more content once you scroll down. Bottom defines the current known bottom coordinate.

horizontal defines where to scroll horizontally. Works same as vertical but defines < left | right > as start and end.

behavior defines whether the scroll happens directly or it scrolls smoothly.

Select Options By

Selects options from select element found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull
attributeSelectAttributenull
valuesnull

Selects options from select element found by selector.

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

Matches based on the chosen attribute with list of values. Possible attributes to match options by: attribute

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

SessionStorage Clear

Remove all saved data from the session storage.

SessionStorage Get Item

Get saved data from from session storage.

Arguments

Argument Type Default value Description
keystrnull
assertion_operatorAssertionOperatorNone
assertion_expectedAnyNone

key Named key of the item in the storage.

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

SessionStorage Remove Item

Remove saved data with key from the session storage.

Arguments

Argument Type Default value Description
keystrnull

key Name of the item which shall be deleted.

SessionStorage Set Item

Save data to session storage.

Arguments

Argument Type Default value Description
keystrnull
valuestrnull

key The name of the key under which it should be saved.

value The value which shall be saved as a string.

Set Browser Timeout

Sets the timeout used by most input and getter keywords.

Arguments

Argument Type Default value Description
timeouttimedeltanull

timeout Timeout of it is for current playwright context.

Returns the previous value of the timeout.

Set Geolocation

Updated the correct Context's geolocation.

Arguments

Argument Type Default value Description
latitudefloatnull
longitudefloatnull
accuracyfloatNone

Latitude can be between -90 and 90 and longitude can be between -180 and 180.

Set Offline

Toggles current Context's offline emulation.

Arguments

Argument Type Default value Description
offlineboolTrue

offline Toggles the offline mode. Set to False to switch back to online mode. Defaults to True.

Set Retry Assertions For

Sets the timeout used in retrying assertions when they fail.

Arguments

Argument Type Default value Description
timeouttimedeltanull

timeout

Returns the previous value of the retry_assertions_until.

Set Viewport Size

Sets current Pages viewport size to specified dimensions.

Arguments

Argument Type Default value Description
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.

width Sets the width size.

height Sets the heigth size.

Switch Browser

Switches the currently active Browser to another open Browser. Returns a stable identifier for the previous browser. See `Browser, Context and Page` for more information about Browser and related concepts.

Arguments

Argument Type Default value Description
idstrnull

Switches the currently active Browser to another open Browser. Returns a stable identifier for the previous browser. See Browser, Context and Page for more information about Browser and related concepts.

id Id of the browser to be changed to. Starting at 0.

Switch Context

Switches the active BrowserContext to another open context. Returns a stable identifier for the previous context. See `Browser, Context and Page` for more information about Context and related concepts.

Arguments

Argument Type Default value Description
idstrnull
browserstrCURRENT

Switches the active BrowserContext to another open context. Returns a stable identifier for the previous context. See Browser, Context and Page for more information about Context and related concepts.

id Id of the context to be changed to. Randomly generated UUID.

browser < CURRENT | str> Switch context in specified browser. If value is not "CURRENT" it should be an the id of the browser where to switch context.

Switch Page

Switches the active browser page to another open page by ``id`` or ``NEW``. Returns a stable identifier ``id`` for the previous page. See `Browser, Context and Page` for more information about Page and related concepts.

Arguments

Argument Type Default value Description
idstrnull
contextstrCURRENT
browserstrCURRENT

Switches the active browser page to another open page by id or NEW. Returns a stable identifier id for the previous page. See Browser, Context and Page for more information about Page and related concepts.

id < CURRENT | NEW | str> Id of the page to be changed to or

NEW for a page opened after the current page. This may timeout if no new pages exists before library timeout. See Set Browser Timeout for how to change the timeout.

With CURRENT you can get the id of the "CURRENT" page

context < CURRENT | str> Switch page in specified context. If value is not "CURRENT" it should be the id of the context where to switch page.

browser < CURRENT | str> Switch page in specified browser. If value is not "CURRENT" it should be the id of the browser where to switch page.

Take Screenshot

Takes a screenshot of the current window and saves it to ``path``. Saves it as a png.

Arguments

Argument Type Default value Description
filenamestrrobotframework-browser-screenshot-{index}
selectorstr
fullPageboolFalse

Takes a screenshot of the current window and saves it to path. Saves it as a png.

filename Filename into which to save. The file will be saved into the robot framework ${OUTPUTDIR}/browser/screenshot directory by default. String {index} in filename will be replaced with a rolling number. Use this to not override filenames. If filename equals to EMBED (case insensitive), 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.

selector Take a screenshot of the element matched by selector. See the Finding elements section for details about the selectors. If not provided take a screenshot of current viewport.

fullPage When True, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to False.

Type Secret

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

Arguments

Argument Type Default value Description
selectorstrnull
secretstrnull
delaytimedelta0:00:00
clearboolTrue

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

This keyword does not log secret in Robot Framework logs. 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.

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

secret Environment 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.

Example: $Password and ${Password} resolve the robot framework variable. %ENV_PWD and %{ENV_PWD} resolve to the environment variable ENV_PWD.

delay Delay between the single key strokes. It may be either a number or a Robot Framework time string. Time strings are fully explained in an appendix of Robot Framework User Guide. Defaults to 0 ms. Example: 50 ms

clear Set to false, if the field shall not be cleared before typing. Defaults to true.

See Type Text for details.

Type Text

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

Arguments

Argument Type Default value Description
selectorstrnull
textstrnull
delaytimedelta0:00:00
clearboolTrue

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

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

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

text Text for the text field.

delay Delay between the single key strokes. It may be either a number or a Robot Framework time string. Time strings are fully explained in an appendix of Robot Framework User Guide. Defaults to 0 ms. Example: 50 ms

clear Set to false, if the field shall not be cleared before typing. Defaults to true.

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

Uncheck Checkbox

Unchecks the checkbox found by ``selector``.

Arguments

Argument Type Default value Description
selectorstrnull

Unchecks the checkbox found by selector.

selector Selector of the checkbox. See the Finding elements section for details about the selectors.

Does nothing if the element is not checked/selected.

Upload File

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

Arguments

Argument Type Default value Description
pathstrnull

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

path Path to file to be uploaded.

Example use:

Upload File    ${CURDIR}/test_upload_file
Click          \#file_chooser

Wait For

Waits for promises to finish and returns results from them. Returns one result if one promise waited. Otherwise returns an array of results. If one fails, then this keyword will fail.

Arguments

Argument Type Default value Description
promisesFuturenull

promises Work in progress

Examples

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

Wait For All Promises

Waits for all promises to finish. If one fails, then this keyword will fail.

Wait For Download

Waits for next download event on page. Returns file path to downloaded file.

Arguments

Argument Type Default value Description
saveAsstr

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

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

saveAs Filename to save as. File will also temporarily be saved in playwright context's default download location.

Example usage:

New Context      acceptDownloads=True
New Page         ${LOGIN_URL}
${dl_promise}    Promise To  Wait For Download
Click            \#file_download
${file_path}=    Wait For  ${dl_promise}

Wait For Elements State

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

Arguments

Argument Type Default value Description
selectorstrnull
stateElementStatevisible
timeouttimedeltaNone
messagestrNone

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

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.

selector Selector of the corresponding object. See the Finding elements section for details about the selectors.

state See ElementState for explaination.

Note that element without any content or with display:none has an empty bounding box and is not considered visible.

timeout uses default timeout of 10 seconds if not set.

message overrides the default error message. The message argument accepts {selector}, {function}, and {timeout} format options. The {function} formatter is same state argument value.

Wait For Function

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

Arguments

Argument Type Default value Description
functionstrnull
selectorstr
pollingstr, timedeltaraf
timeouttimedeltaNone
messagestrNone

function A valid javascript function or a javascript function body. For example () => true and true will behave similarly.

selector Selector 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.

polling Default polling value of "raf" polls in a callback for requestAnimationFrame. Any other value for polling will be parsed as a robot framework time for interval between polls.

timeout Uses default timeout of 10 seconds if not set.

message overrides the default error message. The message argument accepts {selector}, {function}, and {timeout} format options.

Example usage:

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

Wait For Request

Waits for request matching matcher to be made.

Arguments

Argument Type Default value Description
matcherstr
timeouttimedeltaNone

matcher Request URL string, JavaScript regex or JavaScript function to match request by. By default (with empty string) matches first available request.

timeout Timeout in seconds. Uses default timeout if not set.

Wait For Response

Waits for response matching matcher and returns python dict with contents.

Arguments

Argument Type Default value Description
matcherstr
timeouttimedeltaNone

matcher Request URL string, JavaScript regex or JavaScript function to match request by. By default (with empty string) matches first available request.

timeout Timeout in seconds. Uses default timeout if not set.

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.
  • request <dict> containing method <str>, headers <dict> and postData <dict> | <str>

Wait Until Network Is Idle

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

Arguments

Argument Type Default value Description
timeouttimedeltaNone

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

timeout Timeout in milliseconds. Uses default timeout of 10 seconds if not set.