Skip to main content

Locator Level Timeouts

Since v2.19.0

Gwen supports specifying locator level timeouts for overriding the default timeout gwen.web.locator.wait.seconds. This is useful for cases where you may want to increase the locator timeout period for some web elements without impacting others. A web element that takes a long time to load for example can have a higher locator timeout without slowing down the rest of your locators.

Timeout Annotations

Since v2.73.0

Syntax

@Timeout('<duration>')

Where:

  • <duration> can be any of:
    • #h#m#s#ms for a number of hours, minutes, seconds and milliseconds - example: @Timeout('1h2m30s100ms')
    • #h#m#s for a number of hours, minutes and seconds - example: @Timeout('1h2m30s')
    • #h#m#ms for a number of hours, minutes and milliseconds - example: @Timeout('1h2m100ms')
    • #h#ms for a number of hours and milliseconds - example: @Timeout('1h100ms')
    • #h for a number of hours - example: @Timeout('1h')
    • #m#s#ms for a number of minutes, seconds and milliseconds - example: @Timeout('2m30s100ms')
    • #m#s for a number of minutes and seconds - example: @Timeout('2m30s')
    • #m#ms for a number of minutes and milliseconds - example: @Timeout('2m100ms')
    • #m for a number of minutes - example: @Timeout('2m')
    • #s#ms for a number of seconds and milliseconds - example: @Timeout('30s100ms')
    • #s for a number of seconds - example: @Timeout('30s')
    • #ms for a number of milliseconds - example: @Timeout('100ms')
    • 0h for no timeout period - example: @Timeout('0h')
    • 0m for no timeout period - example: @Timeout('0m')
    • 0s for no timeout period - example: @Timeout('0s')
    • 0ms for no timeout period - example: @Timeout('0ms')

The timeout annotation can be used used on various wait, until/while, for each, assertion or locator steps.

Delay Annotation

The same duration patterns also apply to @Delay annotations used to control the delay time between repeated operations in the various wait, until/while loops.

Examples

  # will cause lookup to fail immediately if username is not present on the page
And @Timeout('0s') the username can be located by id "username"

# will cause lookup to fail if the username is not available on the page after waiting 20 seconds
And @Timeout('20s') the username can be located by id "username"

# will cause lookup to fail if the username is not available on the page after waiting 1 minute and 30 seconds
And @Timeout('1m30s') the username can be located by id "username"