2017-02-23 10 views
0

私はキュウリから始めています。私は自分のレールに新しいムービーを作成するテストをしようとしています。だから私のteste1.featureでレール上にフィールド(Capybara :: ElementNotFound)が見つかりません

Feature: É possivel acessar a pagina de Novo Filme 



Scenario: É possivel visitar paginas 
    Given I visit "/articles" 
    And I press the "Novo Filme" button 
    Then I should see the "/articles/new" page 



Scenario: Add a movie 

    Given I visit "/articles" 
    And I press the "Novo Filme" button 
    Then I should see the "/articles/new" page 
    Given I am on a new movies page 
    When I fill in "article_title" with "Sta Uors" 
    And I fill in "f.number_field" with "10.5" 
    And I press "Salvar Novo Filme" 
    Then I should see "/articles" 
    Then I should see the "Sta Uors" at "tabelafilme" 

と私のteste1.stepに私は

#Given(/^I visit "([^"]*)"$/) do 


# visit article_path # Write code here that turns the phrase above into concrete actions 
#end 
Given (/^I visit "(.*)"/) do |place| 
visit place 
end 

And(/^I press the "([^"]*)" button$/) do |arg| 
    click_on(arg) # Write code here that turns the phrase above into concrete actions 
end 


Then(/^I should see the "([^"]*)" page$/) do |place| 
    visit "/articles/new" 
end 




Given (/^I am on a new movies page/) do 
    visit "/articles/new" 
end 

When (/^I fill in "(.*)" with "(.*)"/) do |field , content| 
fill_in (field), :with => (content), visible: false 
end 

And(/^I press "([^\"]*)"/) do |button| 
    click_button(button) 
end 

Then (/^I should see "([^\"]*)"/) do |arg| 
    page.find_by_id('notice').text == arg 
end 

Then (/^I should see the "([^\"]*)" at "([^\"]*)"/) do |film, table| 
    expect(page).to have_css("#tebelafilme", :text => table) 
    find('td', text: film) 
end 

を持っていますが、私はまだ私がプロジェクトに行くので、このエラーに

When I fill in "article_Titulo" with "Sta Uors" # features/step_definitions/teste1.rb:24 
    Unable to find field "article_Titulo" (Capybara::ElementNotFound) 
    ./features/step_definitions/teste1.rb:25:in `/^I fill in "(.*)" with "(.*)"/' 
    features/teste1.feature:18:in `When I fill in "article_Titulo" with "Sta Uors"' 

を取得しています私のarticle_titleをクリックしてhtmlページを調べると、キュウリに付ける名前は何ですか?ID名は「article_text」、ラベルは「article_Titulo」です。キュウリはフィールドを見つけることができません。 誰かが私を助けることができますか?

答えて

1

fill_inの最初の数字はthe documentationです。これらの引数の両方の文字列が必要です。 fill_in "#{field}", :with => "#{content}", visible: falseを実行して、文字列を入力していることに疑いはありません。

ただし、text_fieldヘルパーメソッドを使用してフィールドを作成する場合は、this answerとする必要があります。名前にアンダースコアを付けて作成された要素のように、DOMに到達するまでにアンダースコアが削除されているようです。

関連する問題