2011-04-14 2 views
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 

답변

1

올바른 삭제 링크 레일을 생성하는 자바 스크립트를 사용합니다. 따라서 GET 대신 DELETE 요청을 받아 정상 링크가 생성합니다. webrat은 자바 스크립트를 처리하지 않기 때문에이 방법이 없습니다. 셀리브니움과 함께 webrat 또는 webrat의 대안으로 Capybara를 확인하십시오.

+0

카피 바라가 설치되어 있고 삭제 링크를 클릭 할 수 있지만 두 번째 링크는 클릭 할 수 없습니다. – map7

+0

Capybara가 설치되어 있지만 오이에서 webrat 대신 사용해야합니다 (루비 스크립트/무언가를 설치 한 후에 https://github.com/aslakhellesoy/cucumber-rails를 참조하십시오/오이 생성 --capybara) . 삭제 링크를 클릭 할 수 있지만 두 번째 링크는 클릭 할 수 없다는 것은 무엇을 의미합니까? 나는 이해하지 못한다. – wrtsprt

+0

내가 말하는 것은 직원 목록을 가지고 있으며 목록에있는 각 직원에 대한 삭제 링크가 있습니다. 가능하다면 오이가 두 번째 삭제 링크를 클릭하도록하고 싶습니다. – map7