2012-01-09 104 views
1

運行最新版本的Rails,Cucumber和Capybara當Capybara需要按下按鈕時,我陷入困境。我試圖消除所有問題,並確保窗體生成並正確顯示。 B)如果我嘗試按下帶有完全不正確的標識或文本值的按鈕(如果我嘗試按下具有正確標識或文本值('提交')的按鈕B)如果我嘗試按下具有完全不正確標識或文本值的按鈕( 'cxxxommit')導軌,黃瓜,水豚 - 黃瓜一步不能按下按鈕

我可以重現上都Ubuntu和Windows 7的

的錯誤這些錯誤:

選項A

And I save the Quote 
    undefined method `name' for nil:NilClass (ActionView::Template::Error) 
    C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/whiny_nil.rb:48:in `method_missing' 

選項B

And I save the Quote 
     no button with value or id or text 'cxxxommit' found (Capybara::ElementNotFound) 
     (eval):2:in `click_button' 
     ./features/step_definitions/quote_steps.rb:63:in `/^I save the Quote$/' 
     features\interactions\policies\quotes.feature:22:in `And I save the Quote' 

版本

紅寶石1.9.2p290(2011-07-09)[I386-的mingw32]

的Rails 3.1.3

場景

Scenario: Create a complete manual entered quote for a client 
    When I select the XXX as YYY   
    And I save the Quote 
    Then I should see "Policy was successfully created" 

步驟

When /^I select the (.*) as (.*)$/ do |field, value| 
    select(value, :from => field) 
end 

When /^I save the Quote$/ do 
    # debugger 
    click_button('commit') 
    # ================================================ 
    # The next line causes the second error 
    # click_button('cxxxommit') 
    # ================================================ 
    # find_button('commit').click 
end 

請注意,我已閱讀並嘗試以下SO發佈Cucumber press button failure (Capybara::ElementNotFound)

List of gems in use

任何幫助或方向將不勝感激。

謝謝

+0

這裏有一些不一致之處。您的方案是針對項目,而不是報價。此外,您的錯誤消息表明,當您向我們提供的步驟代碼表示「提交」時,它找不到'cxxxommit'。此外,你有兩個「選項」的錯誤信息?您沒有向我們展示哪些代碼會導致哪些錯誤消息。請編輯問題並解決這些問題,並最好向我們展示一個最小失敗情況。 – 2012-01-09 12:45:28

+0

@MarkThomas:感謝您的快速反饋。我已經更新了這個問題以反映最初的問題,在不同的項目中工作會打亂我的大腦。 – 2012-01-10 06:24:03

+0

HTML的外觀如何?它是一個輸入元素或JavaScript操作? – 2012-01-10 12:24:10

回答

0

你能告訴我什麼是以下代碼中的項目?我想它應該是報價

Scenario: Create a complete manual entered quote for a client 
    When I select the XXX as YYY   
    And I save the Item 
    Then I should see "Item was successfully created" 
+0

100%正確。感謝您的反饋,請參閱更新後的帖子。 – 2012-01-10 06:26:49