Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 2.47 KB

timeouts.adoc

File metadata and controls

70 lines (49 loc) · 2.47 KB

Timeouts

Table of Contents

Almost all QWeb keywords have an inbuilt timeout, i.e they keep re-trying to find elements and do their action until action succeeds OR until timeout limit is reached. By default this timeout limit is 10 seconds.

You can change this timeout temporarily by giving an argument timeout:

VerifyText      Username    timeout=3       # only wait 3 seconds for element to appear
ClickText       Login       timeout=30      # wait max 30 seconds for element to appear

You can also change timeouts for every keyword (globally) with SetConfig:

SetConfig     DefaultTimeout    60   # sets default timeout to 60 seconds, affecting all keywords

After setting defaultTimeout with Setconfig, you can use keywords without any arguments:

SetConfig       DefaultTimeout    60
VerifyText      Username    # would wait 60 seconds for text to appear before failing
ClickText       Login       # would wait max 60 seconds for element to appear

This is especially useful in case you run your tests against different environments that may have different resources; you can dynamically set the timeout based on environment under test.



ℹ️
Try to avoid Sleep keyword as much as possible. The difference between QWeb’s timeouts and Sleep keyword is that Sleep will ALWAYS wait until given time before proceeding to next keyword; QWeb timeouts will move to next keyword as soon as element is available.

Exercise

To really see how timeouts work, we’ll create 3 failing test cases with different timeouts.

  1. Open Browser and Go to https://qentinelqi.github.io/shop/

  2. Verify non-existing text using default timeout, 15 second timeout and 45 second timeout

  3. Run the test suite and examine the logs. Was the timeout as expected?

Solution

Exercise example solution can be found the repo. Please try to implement your own solution first before looking at the provided solution.

Run this solution from repo root by:

robot ./06/06_solution.robot