如何解决黄瓜webrat单击第二个删除链接
| 我有一种情况,我想在页面上为表中的第二项选择\'Delete \'链接。我一直在查看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
这是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
解决方法
为了生成正确的删除链接,rails使用javascript。因此,您会收到一个DELETE请求,而不是普通链接将产生的GET请求。由于webrat无法处理javascript,因此无法正常工作。查看Capybara,以替代webrat或带硒的webrat。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。