Until/While
Since v3.48.0, the following implicit attributes are available to
<step>s:
gwen.iteration.number= current iteration starting at 1gwen.iteration.index= current iteration starting at 0
<step> <until|while> <condition>
Repeatedly exectues a step until or while a condition is satisfied using a default delay and timeout period. The default delay between iterations is one tenth of the configured gwen.web.wait.seconds setting (or 1 second if not set). The default timeout period is 30 times the delay. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> <condition>
gwen.web.wait.seconds setting (or 1 second if not set). The default timeout period is 30 times the delay. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the condition is satisfiedwhileto repeat while the condition is satisfied
<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
The following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
Example
Given the search field can be located by name "q"
And the next page link can be located by id "pnnext"
And topic is "what is gwen"
And topic link can be located by partial link text "${topic}"
And topic not found is defined by js
"""
[...document.querySelectorAll("a")]
.filter(a => a.textContent.includes('${topic}'))
.length == 0
"""
When I navigate to "https://google.com"
And I enter "gwen interpreter" in the search field
And I click the next page link while topic not found
And I click topic link
Then the page title should contain "${topic}"
With explicit delay and timeout since v3.73.0
Given the search field can be located by name "q"
And the next page link can be located by id "pnnext"
And topic is "what is gwen"
And topic link can be located by partial link text "${topic}"
And topic not found is defined by js
"""
[...document.querySelectorAll("a")]
.filter(a => a.textContent.includes('${topic}'))
.length == 0
"""
When I navigate to "https://google.com"
And I enter "gwen interpreter" in the search field
And @Delay('10s') @Timeout('1m') I click the next page link while topic not found
And I click topic link
Then the page title should contain "${topic}"
With no delay or timeout since v3.73.0
Given the search field can be located by name "q"
And the next page link can be located by id "pnnext"
And topic is "what is gwen"
And topic link can be located by partial link text "${topic}"
And topic not found is defined by js
"""
[...document.querySelectorAll("a")]
.filter(a => a.textContent.includes('${topic}'))
.length == 0
"""
When I navigate to "https://google.com"
And I enter "gwen interpreter" in the search field
And @Delay('0s') @Timeout('0s') I click the next page link while topic not found
And I click topic link
Then the page title should contain "${topic}"
<step> <until|while> <element> is[ not] <state>
Repeatedly exectues a step until or while an element is in a given state using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> <element> is[ not] <state>
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the condition is satisfiedwhileto repeat while the condition is satisfied
<element>is the name of the element to check the state ofnotnegates the state if included<state>is one of:displayedto execute the step until or while the element is displayedhiddento execute the step until or while the element is not displayedcheckedortickedto execute the step until or while a checkbox is tickeduncheckedoruntickedto execute the step until or while a checkbox is not tickedenabledto execute the step until or while the element is enableddisabledto execute the step until or while the element is disabled
The following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
Example
Given the search field can be located by name "q"
And the next page link can be located by id "pnnext"
When I navigate to "https://google.com"
And I enter "gwen interpreter" in the search field
And I click the next page link while the next page link is displayed
Then the next page link should not be displayed
With explicit delay and timeout since v3.73.0
Given the search field can be located by name "q"
And the next page link can be located by id "pnnext"
When I navigate to "https://google.com"
And I enter "gwen interpreter" in the search field
And @Delay('5s') @Timeout('40s') I click the next page link while the next page link is displayed
Then the next page link should not be displayed
With no delay or timeout since v3.73.0
Given the search field can be located by name "q"
And the next page link can be located by id "pnnext"
When I navigate to "https://google.com"
And I enter "gwen interpreter" in the search field
And @Delay('0s') @Timeout('0s') I click the next page link while the next page link is displayed
Then the next page link should not be displayed
<step> <until|while> <name> is[ not] defined
Repeatedly exectues a step until or while an attribute is defined (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> <name> is[ not] defined
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<name>is the name of the attribute (or StepDef <param> since v4.11.0) to checknotinclude to execute step until or while attribute is not definedThe following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <until|while> "<filepath>" file[ not] exists
Repeatedly exectues a step until or while a file exists (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> "<filepath>" file[ not] exists
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<filepath>the path to the file to checknotto wait until the file does not exist (negation)The following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <until|while> "<filepath>" file does not exist
Repeatedly exectues a step until or while a file does not exist using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> "<filepath>" file does not exist
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<filepath>the path to the file to checkThe following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <until|while> "<filepath>" file is[ not] empty
Repeatedly exectues a step until or while a file is empty (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> "<filepath>" file is[ not] empty
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<filepath>the path to the file to checknotto wait until the file is not empty (negation)The following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <until|while> <filepathRef file>[ not] exists
Repeatedly exectues a step until or while a file exists (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> <filepathRef file>[ not] exists
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<filepathRef file>is the name of the binding containing the path of the file to checknotto wait until the file does not exist (negation)The following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <until|while> <filepathRef file> does not exist
Repeatedly exectues a step until or while a file does not exist using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> <filepathRef file> does not exist
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<filepathRef file>is the name of the binding containing the path of the file to checkThe following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <until|while> <filepathRef file> is[ not] empty
Repeatedly exectues a step until or while a file is empty (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <until|while> <filepathRef file> is[ not] empty
@Delay and @Timeout annotations.Where
<step>is the DSL step or StepDef to execute in each iteration<until|while>is one of:untilto repeat until the attribute is defined (or not)whileto repeat while the attribute is defined (or not)
<filepathRef file>is the name of the binding containing the path of the file to checknotto wait until the file is not empty (negation)The following implicit binding is available in
<step>:iteration number(orgwen.iteration.numbersince v2.52.0) is the current iteration number (starting at 1)
<step> <while|until> <name> is[ not] <blank|empty>
Repeatedly exectues a step until or while an element or attribute is bound to a blank or empty value (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <while|until> <name> is[ not] <blank|empty>
Where
<step>is the DSL step or StepDef to repeatedly execute<name>is the name of the element or attribute (or StepDef <param> since v4.11.0) to checknotto negate the condition
Example
Given the state code can be located by name "state"
When I navigate to "https://example.com"
And I refresh the current page while the state code is blank
<step> <while|until> <name> is[ not] "<value>"
Repeatedly exectues a step until or while an element or attribute is equal to a value (or not) using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <while|until> <name> is[ not] "<value>"
Where
<step>is the DSL step or StepDef to repeatedly execute<name>is the name of the element or attribute (or StepDef <param> since v4.11.0) to checknotto negate the conditionvalueis the given value
Example
Given the state code can be located by name "state"
When I navigate to "https://example.com?state=Victoria"
And I refresh the current page while the state code is not "VIC"
Trimming and ignoring case
- The
@Trimannotation can be used on step to trim strings when comparing - The
@IgnoreCaseannotation can be used on step to ignore case when comparing
<step> <while|until> <name> <match> "<expression>"`
Repeatedly exectues a step until or while an element or attribute matches an expression using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <while|until> <name> <match> "<expression>"`
Where
<step>is the DSL step or StepDef to repeatedly execute<name>is the name of the element or attribute (or StepDef <param> since v4.11.0) to check<match>is the type of match to perform, one of:containsfor partial matchstarts withfor partial leading matchends withfor partial trailing matchmatches regexfor regex matchmatches xpathfor XML matchmatches json pathfor JSON match, since v1.4.0matches templatefor template match, since v2.16.0matches template filefor template file match, since v2.16.0
<expression>is the expression to match (can be in DocString position)
Example
Given the state code can be located by name "state"
When I navigate to "https://example.com?state=${the state code}"
And I refresh the current page until the state code matches regex "(VIC|NSW)"
Trimming and ignoring case
- The
@Trimannotation can be used on step to trim strings when comparing - The
@IgnoreCaseannotation can be used on step to ignore case when comparing
<step> <while|until> <name> does not <match> "<expression>"`
Repeatedly exectues a step until or while an element or attribute does not match an expression using a 1 second delay interval and 1 minute timeout period. The default delay and timeout can be overridden using the @Delay and @Timeout annotations.
<step> <while|until> <name> does not <match> "<expression>"`
Where
<step>is the DSL step or StepDef to repeatedly execute<name>is the name of the element or attribute (or StepDef <param> since v4.11.0) to check<match>is the type of match to perform, one of:containfor partial matchstart withfor partial leading matchend withfor partial trailing matchmatche regexfor regex matchmatche xpathfor XML matchmatche json pathfor JSON match, since v1.4.0matche templatefor template match, since v2.16.0matche template filefor template file match, since v2.16.0
<expression>is the expression to match (can be in DocString position)
Example
Given the state code can be located by name "state"
When I navigate to "https://example.com?state=${the state code}"
And I refresh the current page until the state code does not match regex "(VIC|NSW)"
Trimming and ignoring case
- The
@Trimannotation can be used on step to trim strings when comparing - The
@IgnoreCaseannotation can be used on step to ignore case when comparing