2013-07-21 3 views
0

나는 오이 카피 바라 새로운 오전과 나는 다음과 같은 오류가 의아해입니다 : 내가 가진카피 바라 & 오이 CSS 로케이터를 찾을 수 없습니다

When I click the "Search" button # features/step_definitions/web_steps.rb:9 
    Unable to find button #<Capybara::Element tag="button"> (Capybara::ElementNotFound) 
    ./features/step_definitions/web_steps.rb:11:in `/^I click the "([^"]*)" button$/' 
    features/search.feature:9:in `When I click the "Search" button' 

내 기능 내 :

When I click the "Search" button 

내 단계는 같다 :

When /^I click the "([^"]*)" button$/ do |button_text| 
    button_text = find('#gbqfb') 
    click_button button_text 
end 

나는 'click (button_text) 및 click_link 메소드를 시도했다. 나는 내가 볼 수 없다는 것을 분명히 알았습니다. 버튼 요소에 대한 CSS 로케이터를 찾은 다음 해당 요소를 클릭하려고합니다. 나는 'button_text'지역 변수가 어쨌든 변경 되었기 때문에 정규 표현식을 변경할 필요가 없다고 생각합니다. 아니면 내가?

답변

0

당신은 당신의 오이이

first('.page a', :text => '2').click 
find('.page a', :text => '2').click 

같은 설정을 클릭 한 후 firstfind 방법을 사용할 수 있습니다

When /^I click the "([^"]*)" button$/ do |button_text| 
    first('.page a', :text => "#{button_text}").click 
end 

또는

When /^I click the "([^"]*)" button$/ do |button_text| 
    find('.page a', :text => "#{button_text}").click 
end 
관련 문제