Sleeps and waits
I wait for <element>
Waits for an element to appear on a page for a default number of seconds before timing out. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait for <element>
@Timeout annotation.I wait for <element> text
Waits for the text of an element to appear on a page for a default number of seconds before timing out.
I wait for <element> text
I wait until <element> is[ not] <state>
Waits for an element to transition to a given state. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until <element> is[ not] <state>
@Timeout annotation.Where
<element>is the name of the element to wait fornotnegates the state if included<state>is one of:displayedto wait until the element is displayedhiddento wait until the element is not displayedchecked(ortickedsince v2.4.0) to wait until a checkbox is tickedunchecked(oruntickedsince v2.4.0) to wait until a checkbox is not tickedenabledto wait until the element is enableddisabledto wait until the element is disabled
Example
Given my todo list can be located by css ".todo-list"
And the todo field can be located by class "new-todo"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Get the milk" in the todo field
And I wait until my todo list is displayed
I wait until "<javascript>"
Repeatedly executes the given javascript expression or function until true is returned using no delay interval and default timeout period. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until "<javascript>"
gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.Where
<javascript>is the javascript expression or function that will return a boolean value (can be in DocString position)- For a one liner expression, no function, arrow declaration or
returnprefix is required For a function, use either:
- Arrow syntax (preferred):
() => { body }(Since v3.56.0) - Or anonymous function syntax (legacy):
(function(){ body })()
- Arrow syntax (preferred):
- For a one liner expression, no function, arrow declaration or
Example
Given the heading can be located by tag "h1"
When I navigate to "https://challengers.flood.io/start"
And I wait until "!!$('h1')"
Then the heading should be "Welcome to our Script Challenge"
I wait until "<filepath>" file[ not] exists
Waits until a file exists (or not). The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until "<filepath>" file[ not] exists
I wait until "<filepath>" file does not exist
Waits until a file does not exist. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until "<filepath>" file does not exist
I wait until <filepathRef file>[ not] exists
Waits until a file exists (or not). The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until <filepathRef file>[ not] exists
I wait until <filepathRef file> does not exist
Waits until a file does not exist. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until <filepathRef file> does not exist
I wait until "<filepath>" file is[ not] empty
Waits until a file is empty. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until "<filepath>" file is[ not] empty
I wait until <filepathRef file> is[ not] empty
Waits until a file is empty. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until <filepathRef file> is[ not] empty
I wait until <condition>
Waits until a condition is satisfied. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait until <condition>
@Timeout annotation.Where
<condition>is either:Since v3.54.0
- the name of any binding that will return
truewhen the condition is satisfied orfalsewhen it is not
- the name of any binding that will return
Or in prior versions
- the name of a binding containing a javascript function or expression that will return
truewhen the condition is satisfied orfalsewhen it is not - the name of a binding containing a
trueorfalsevalue literal, since v3.50.0
- the name of a binding containing a javascript function or expression that will return
Example
Given the heading can be located by tag "h1"
And the heading is displayed is defined by javascript "!!$('h1')"
When I navigate to "https://challengers.flood.io/start"
And I wait until the heading is displayed
Then the heading should be "Welcome to our Script Challenge"
I wait for the <alert|confirmation> popup
Waits for the alert/confirmation popup to appear on a page for a default number of seconds before timing out. The default timeout period is equal to the configured gwen.web.wait.seconds setting value. The default timeout can be overridden using the @Timeout annotation.
I wait for the <alert|confirmation> popup
@Timeout annotation.Where
<element>is the name of the element to wait for
Example
Given the alert link can be located by id "alert"
When I navigate to "https://www.selenium.dev/selenium/web/alerts.html"
And I click the alert link
And I wait for the alert popup
Then the alert popup message should not be blank