2012-01-24 10 views
11

मैं काम करने के लिए अन्य capybara विधियों जैसे यात्रा, fill_in, चयन आदि प्राप्त कर सकते हैं। लेकिन उस पर क्लिक नहींमुझे ककड़ी :: रेल :: विश्व के लिए अपरिभाषित विधि 'क्लिक' क्यों मिलती है? ककड़ी/कैपिबरा चरणों में

Given /^a no fee license called "([^"]*)"$/ do |arg1| 
    @l = FactoryGirl.create(:license, 
         name: arg1) 
end 

When /^execute the license$/ do 
    visit(license_path(@l)) 
    click('Execute License') 
end 

त्रुटि:

Scenario: no fee license is executed         # features/visitor_no_fee_license.feature:14 
    When I fill out the licensee info with valid info     # features/step_definitions/licenses_steps.rb:21 
    And execute the license           # features/step_definitions/licenses_steps.rb:35 
     undefined method `click' for #<Cucumber::Rails::World:0x007feebad4dec8> (NoMethodError) 
     ./features/step_definitions/licenses_steps.rb:37:in `/^execute the license$/' 
     features/visitor_no_fee_license.feature:16:in `And execute the license' 

उत्तर

1

शायद आप click_link उपयोग करने के लिए मतलब था?

When /^(?:|I)follow "([^"]*)"$/ do |link| 
    click_link(link) 
end 

वहाँ भी click_button

है इनमें से कोई भी आपकी आवश्यकताओं के अनुरूप है, तो आप एक तत्व पर click कॉल कर सकते हैं।

When /^(?:|I)click "([^"]*)" span$/ do |selector| 
    element ||= find('span', :text => selector) 
    element.click 
end 

यदि उपरोक्त में से कोई भी उपयोगी है, तो यहाँ सभी क्लिक तरीकों की एक सूची है, अगर आप एक आप उपयोग करना चाहते पहचान, मैं आगे सहायता करने में सक्षम हो सकता है।

http://rubydoc.info/search/github/jnicklas/capybara/master?q=click

+0

नहीं है, मैं क्योंकि यह एक लिंक या बटन का चयन कर सकते क्लिक करना चाहता था। लेकिन आपकी दूसरी विधि साफ है, धन्यवाद! मुझे जवाब मिला, नीचे पोस्ट किया गया। – Ivan

संबंधित मुद्दे