1
我有一個方案,我想選擇頁面上的'刪除'鏈接表中的第二個項目。我一直在看click_link_within或使用內,但它不能正常工作。黃瓜webrat點擊第二個刪除鏈接
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
這裏是HAML上市代碼:
%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
我已經安裝了水豚,我可以點擊刪除鏈接,但不是第二個鏈接。 – map7 2011-04-17 02:49:42
水豚安裝很好,但你必須確保你使用它而不是在黃瓜webrat(請參閱:https://github.com/aslakhellesoy/cucumber-rails後安裝一些像紅寶石腳本/生成黃瓜 - capybara) 。你是什麼意思,你可以點擊刪除鏈接,但不是第二個鏈接?我不明白。 – wrtsprt 2011-04-18 08:26:10
我的意思是,我有一個工作人員名單,並且我有一個列表中每個工作人員的刪除鏈接。如果可能,我想讓黃瓜點擊第二個刪除鏈接。 – map7 2011-04-18 09:11:29