У меня есть сценарий, в котором я хочу выбрать ссылку «Удалить» на странице для второго элемента в таблице. Я смотрю на click_link_within или использую внутри, но он работает неправильно.
Scenario: User deletes a staff member from the listing
Given a staff exists with name: "Michael"
And a staff exists with name: "Joe"
And I am on the listing staff index page
When I follow "Delete" for row containing "Joe"
Then I should be on the listing staff index page
And I should not see "Joe"
And I should see "Michael"
Вот шаг, который я пытаюсь использовать:
When /^I follow "([^"]*)" for row containing "([^"]*)"$/ do |button, text|
click_link_within "//*[.//td[contains(.,#{text})]]", button
end
А вот код листинга в хамле:
%h1 Staff Listing
%table
%th Username
%th Surname
%th First Name
- @staff.each do |staff|
%tr
%td= staff.username
%td= staff.surname
%td= staff.firstname
%td= link_to "Edit", edit_staff_path(staff)
%td= link_to "Delete", staff, :method => :delete