質問

私のレールを適用しているページのリンクを実施するjavascript関数:

<%= link_to_function("Add an address", "add_fields(this)".html_safe) %>

私のきゅうり機能してい:

And I press "Add an address"

のメッセージを取得します:

Capybara::ElementNotFound: no button with value or id or text 'Add an address' found

私も何かが足りないものが見つからなか..

役に立ちましたか?

解決

にするべきなのは、唯一、以下の

  • 名前の変更をご提出ボタンを作成
  • 変更試験をやってみて、押し"保存"'
  • 追加のボタンのidを変更試験のようになります:

    眺望
    =f.提出'保存',id=>:foo

    試験
    Iを押す"foo"

他のヒント

joaomilhoが解決しよう:

あなたは、次のいずれかの、そして唯一のを、行う必要があります:

「作成」のボタンを提出するあなたの名前を変更 あなたのテストは、「私を押して 『保存』」に変更します あなたのボタンにIDを追加し、さらにテストを変更する、このような:

ビュー = f.submit '保存'、:ID =>:FOO

テスト そして、私は押して "foo" という

1つのシナリオ(渡さ1) 3つのステップ(3渡さ) 0m2.510s

ここで

同じ動作、私が使用しています:

Railsの3キュウリ/カピバラ/ HAML

Feature: Manage posts
  In order to [goal]
  [stakeholder]
  wants [behaviour]

  @wip
  Scenario: Register new post             # features/manage_posts.feature:6
    Given I am on the new post page       # features/step_definitions/web_steps.rb:19
    When I fill in "Title" with "title 1" # features/step_definitions/web_steps.rb:40
    And I fill in "Body" with "body 1"    # features/step_definitions/web_steps.rb:40
    And I uncheck "Published"             # features/step_definitions/web_steps.rb:83
    And I press "Create"                  # features/step_definitions/web_steps.rb:27     
    Then I should see "title 1"           # features/step_definitions/web_steps.rb:108
    And I should see "body 1"             # features/step_definitions/web_steps.rb:108
    And I should see "false"              # features/step_definitions/web_steps.rb:108

ステップ:

When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|   with_scope(selector) do
    click_button(button)
    selenium.wait_for_page_to_load   
    end  
end

表示新しいます:

%h1 New post

= render 'form'

= link_to 'Back', posts_path

エラー:

 no button with value or id or text 'Create' found (Capybara::ElementNotFound)
      ./features/step_definitions/web_steps.rb:29
      ./features/step_definitions/web_steps.rb:14:in `with_scope'
      ./features/step_definitions/web_steps.rb:28:in `/^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/'
      features/manage_posts.feature:11:in `And I press "Create"'

_formます:

= form_for @post do |f| 
  -if @post.errors.any?
    #errorExplanation
      %h2= "#{pluralize(@post.errors.count, "error")} prohibited this post from being saved:"
      %ul 
        - @post.errors.full_messages.each do |msg|
          %li= msg 

  .field
    = f.label :title
    = f.text_field :title
  .field
    = f.label :body
    = f.text_area :body
  .field
    = f.label :published
    = f.check_box :published
  .actions
    = f.submit 'Save'

私はあなたがしたいと考えている。

And I follow "Add an Address"

セバスチャン:あなたのリンクにIDを追加しようと、あなたのテストでの参照、それを

は、のリンクを作成しますが、のボタン

を押ししようとしていたという元の問題はなかったです

慎重にカピバラのドキュメント読んで、あなたは方法が異なって表示されます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top