Skip to main content

3.1 Waiting in Browser Library

3.1.1 Waiting by Playwright.

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

In this example, the last click will wait until the 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 examples/3/3.1/pw_waiting.robot

How long the waiting lasts 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 for one second. 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 examples/3/3.1/assertion_timeout.robot

3.1.3 Other Wait For.. keywords

There are multiple helper keywords that can help in different situations.

3.1.3.1 Wait For Condition

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

3.1.3.2 Wait Until Network Is Idle

This keyword waits until network traffic has been idle for at least 500 milliseconds.

3.1.3.3 Wait For Navigation

This keyword waits until the page has navigated to the URL. The wait_until argument can be used to define the page load status.

3.1.3.4 Wait For Function

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

Loading examples...