Skip to main content

3.1 Waiting in Browser Library

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 examples/3/3.1/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 examples/3/3.1/assertion_timeout.robot

3.1.3 Other Wait For.. keywords

There are multiple helper keywords which can help on 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

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

3.1.3.3 Wait For Navigation

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

3.1.3.4 Wait For Funtion

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

Loading examples...