ForEach
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> for each <element> located by <selector> "<expression>"
Executes a step for each element in a list of elements in the current scope with a default lookup timeout that can be overridden with the @Timeout annotation.
<step> for each <element> located by <selector> "<expression>"
@Timeout annotation.Where
<step>is the DSL step or StepDef to execute for each element<element>is the name that will be assigned to the current element occurrence (element is accessible in<step>by this name)<selector>is the selector type, one of:idfor selecting by id attributenamefor selecting by name attributetag name(ortagsince v2.46.0) for selecting by tag namecss selector(orcsssince v2.46.0) for selecting by css expressionclass name(orclasssince v2.46.0) for selecting by class attributexpathfor selecting by XPathlink textfor selecting by link textpartial link textfor selecting by partial link textjavascript(orjssince v2.46.0) for selecting by JavaScript
<expression>is the selector expression returning one or many elements
Example
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And I tick todo item for each todo item located by css ".todo-list .toggle"
Then the active count should contain "0"
With explicit timeout since v3.73.0
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And @Timeout('10s') I tick todo item for each todo item located by css ".todo-list .toggle"
Then the active count should contain "0"
Without any timeout since v3.73.0
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And @Timeout('0s') I tick todo item for each todo item located by css ".todo-list .toggle"
Then the active count should contain "0"
<step> for each <element> located by <selector> "<expression>" in <containerElement>
Executes a step for each element in a list of elements in a container element in the current scope with a default lookup timeout that can be overridden with the @Timeout annotation.
<step> for each <element> located by <selector> "<expression>" in <containerElement>
@Timeout annotation.Where
<step>is the DSL step or StepDef to execute for each element<element>is the name that will be assigned to the current element occurrence (element is accessible in<step>by this name)<selector>is the selector type, one of:idfor selecting by id attributenamefor selecting by name attributetag name(ortagsince v2.46.0) for selecting by tag namecss selector(orcsssince v2.46.0) for selecting by css expressionclass name(orclasssince v2.46.0) for selecting by class attributexpathfor selecting by XPathlink textfor selecting by link textpartial link textfor selecting by partial link textjavascript(orjssince v2.46.0) for selecting by JavaScript
<expression>is the selector expression returning one or many elements<containerElement>is the name assigned to the container element
Example
Given the todo field can be located by class "new-todo"
And the todo list can be located by class "todo-list"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And I tick todo item for each todo item located by class "toggle" in the todo list
Then the active count should contain "0"
With explicit timeout since v3.73.0
Given the todo field can be located by class "new-todo"
And the todo list can be located by class "todo-list"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And @Timeout('10s') I tick todo item for each todo item located by class "toggle" in the todo list
Then the active count should contain "0"
Without any timeout since v3.73.0
Given the todo field can be located by class "new-todo"
And the todo list can be located by class "todo-list"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And @Timeout('0s') I tick todo item for each todo item located by class "toggle" in the todo list
Then the active count should contain "0"
<step> for each <element> in <elements>
Executes a step for each element in a list of elements in the current scope with a default lookup timeout that can be overridden with the @Timeout annotation.
<step> for each <element> in <elements>
@Timeout annotation.Where
<step>is the DSL step or StepDef to execute for each element<element>is the name that will be assigned to the current element occurrence (element is accessible in<step>by this name)<elements>is the name of the locator binding returning multiple elements
Example
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
And all todo items can be located by css ".todo-list .toggle"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter "Walk the dog" in the todo field
And I enter "Feed the cat" in the todo field
And I tick todo item for each todo item in all todo items
Then the active count should contain "0"
<step> for each data record
Executes a step for each record in a data table.
<step> for each data record
Where
<step>is the DSL step or StepDef to execute for each record- Each field in a record can be accessed in
<step>using the field's associated header name The following implicit bindings are available in
<step>:gwen.table.record.numberis the current record number (starting at 1)gwen.table.record.indexis the record index (starting at 0), since v2.30.1
Example
Feature Scenario: my scenario
Given I have the following active items
Item |
Walk the dog |
Get the milk |
Feed the cat |
@StepDef
@DataTable
Scenario: I have the following active items
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter Item in the todo field for each data record
Then the active count should contain "3"
<step> for each <entry> in <textRef> delimited by "<delimiter>"
Executes a step for each delimited text entry.
<step> for each <entry> in <textRef> delimited by "<delimiter>"
Where
<step>is the DSL step or StepDef to execute for each delimited entry<entry>is the name that will be assigned to the current entry occurrence (entry is accessible in<step>by this name)<textRef>is the name of the binding containing the delimitted values- Can be the name of any binding that contains or resolves to a delmited list of values, including a web element in which case the text in the element will be dynamically retrieved and used.
<delimiter>the delimiter used in<textRef>to separate each value
Example
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
And my items is "Walk the dog, Feed the cat, Get the milk"
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter item in the todo field for each item in my items delimited by ","
Then the active count should contain "3"
<step> for each <entry> in <arrayRef> array"
Executes a step for each text entry in a JSON array.
<step> for each <entry> in <arrayRef> array"
Where
<step>is the DSL step or StepDef to execute for each entry<entry>is the name that will be assigned to the current entry occurrence (entry is accessible in<step>by this name)<arrayRef>is the name of the binding containing the string repersentation of the JSON array- Can be the name of any binding that contains or resolves to a JSON array string, including a web element in which case the text in the element will be dynamically retrieved and used.
Example
Given the todo field can be located by class "new-todo"
And the active count can be located by css ".todo-count"
And my items is
"""
[
"Walk the dog",
"Feed the cat",
"Get the milk"
]
"""
When I navigate to "https://todomvc.com/examples/react/dist"
And I enter item in the todo field for each item in my items array
Then the active count should contain "3"