Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

<- Back

3.1.1 Waiting by Playwright.

By default, before performing action, like click, Playwright performs automatic waiting by doing actionability checks. The waiting depends on which action keyword performs. Also some keywords, like Click supports force argument which will disable actionability checks.

Example the last click will wait that element is available in the DOM.

*** Settings ***
Library    Browser
Resource   ../../variables.resource

*** Test Cases ***
PW Waiting
    New Page    ${WAIT_URL}
    Select Options By    \#dropdown    value    attached
    Click    \#submit
    Click    \#victim

Run example with command:

robot --outputdir output --loglevel debug 3.1.Waiting/examples/pw_waiting.robot

How long waiting is done, is controlled by the library timeout import argument or by using Set Browser Timeout keyword.

3.1.2 Waiting with assertions

By default assertions are retried with one seconds. This can be changed with library retry_assertions_for import argument or by using Set Retry Assertions For keyword.

*** Settings ***
Library    Browser
Resource   ../../variables.resource
Suite Setup    New Browser    headless=False

*** Test Cases ***
Default Assertion timeout
    New Page    ${WAIT_URL}
    Click    \#setdelay
    Select Options By    \#dropdown    value    attached
    Click    \#submit
    TRY
        Get Text    \#victim    ==    Not here
    EXCEPT    *    type=GLOB
        No Operation
    END

Change timeout
    New Page    ${WAIT_URL}
    ${old_timeout} =    Set Retry Assertions For    2s
    Click    \#setdelay
    Select Options By    \#dropdown    value    attached
    Click    \#submit
    TRY
        Get Text    \#victim    ==    Not here
    EXCEPT    *    type=GLOB
        No Operation
    END
    [Teardown]    Set Retry Assertions For    ${old_timeout}

Run example with command:

robot --outputdir output --loglevel debug 3.1.Waiting/examples/assertion_timeout.robot

3.1.3 Other Wait For.. keywords

There are multiple helper keywords which can help on different situations.

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

keyword will wait that the network traffic has stopped at least for 500milliseconds.

keyword will wait that page has navigated to URL. The wait_until argument can be used to define the page load status.

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