I have the same example so I hope it helps you
1) Senario:
@create-product-backlog-with-multi-assign-to
Scenario: Create a product backlog successfully
Given I am on the new product backlog page
#Then show me the page
When I fill in a form with the following multiple values:
|Project Title |Project 1 |
|Type |Features |
|Title |Product Backlog 8|
|Priority |Urgent |
# Product Backlog must have "State" is "Not Started" initially
|State |Not Started |
|Description |description 8 |
|Assign To |developer,tester |
|Estimated Hours | 48 |
|Business Value | 1 |
|ROI |0.02 |
#|Attachment files| |
# ROI is calculated from Business Value/Estimated Hours and this field is disable
And I click on "Save" button
Then I should be redirected to the product backlog index page
#When I wait 5 seconds
#When I select "All sprints" from "search_sprint_id"
Then show me the page
#When I wait 5 seconds
# product backlog will assign to current user by default
Then I should see a table with the following rows
|ID|Title |Priority|ROI |State |Assign To |Estimated |Actions|
|* |Product Backlog 8| Urgent |0.02 |Not Started |admin,developer,tester|48 |* |
- "Assign To" is select tag
2) Step definitions
When(/^I fill in a form with the following multiple values:$/) do |table|
expectations = table.raw
expectations.each do |label, expected_value|
field = find_field("#{label}")
case field.tag_name
when 'select'
expected_value.split(',').each do |value|
step %(I select "#{value}" from "#{label}")
end
when 'checkbox','radio'
step %(I check "#{label}") unless expected_value.nil?
else
step %(I fill in "#{label}" with "#{expected_value}")
end
end
end