2015-09-16 2 views
0

Когда я просматриваю источник, идентификатор текстового поля соответствует тому, что я вызываю в тесте.Cucumber/Capybara не находит поле simple_form

Вот поле формы: <fieldset class="fsStyle">
<legend class="legendStyle">*** Summarize Your Edits for History/Timeline ***</legend> <%= f.input :latest_update, input_html: { id: 'blurb' } %> <%= f.input :send_update %> </fieldset>

вот огурчик особенность:

`` `

Feature: Edit article with blurbs 
    In order to send a clear update 
    As an editor 
    I want to add a summary of my edits 

Scenario: Article Edit With Blurb 
    Given I am on the show page 
    And I follow "Edit" 
    When I fill in "blurb" with "This is my edit summary" 
    And I press "Update Article" 
    And visit the history page 
    Then I should see "This is my edit summary" 

` ``

определение шага: Given(/^I follow "(.*?)"$/) do |link_name| click_link link_name end

источник вид: `` `

<fieldset class="fsStyle">    
     <legend class="legendStyle">*** Summarize Your Edits for History/Timeline ***</legend> 
     <div class="form-group text optional article_latest_update"><label class="text optional control-label" for="blurb">Latest update</label><textarea id="blurb" class="text optional form-control" name="article[latest_update]"> 
a test update to check boolean</textarea></div> 
     <div class="form-group boolean optional article_send_update"><div class="checkbox"><input value="0" type="hidden" name="article[send_update]" /><label class="boolean optional" for="article_send_update"><input class="boolean optional" type="checkbox" value="1" checked="checked" name="article[send_update]" id="article_send_update" />Send update</label></div></div> 
    </fieldset> 

` ``

Вот результат теста, включая ошибки: `` `

Using the default profile... 
Feature: Edit article with blurbs 
    In order to send a clear update 
    As an editor 
    I want to add a summary of my edits 

    Scenario: Article Edit With Blurb      # features/edit_with_blurbs.feature:6 
    Given I am on the show page       # features/step_definitions/path_steps.rb:4 
    And I follow "Edit"         # features/step_definitions/general_steps.rb:4 
    When I fill in "blurb" with "This is my edit summary" # features/step_definitions/general_steps.rb:8 
     Unable to find field "blurb" (Capybara::ElementNotFound) 
     ./features/step_definitions/general_steps.rb:9:in `/^I fill in "(.*?)" with "(.*?)"$/' 
     features/edit_with_blurbs.feature:9:in `When I fill in "blurb" with "This is my edit summary"' 
    And I press "Update Article"       # features/step_definitions/general_steps.rb:12 
    And visit the history page       # features/step_definitions/path_steps.rb:10 
    Then I should see "This is my edit summary"   # features/step_definitions/general_steps.rb:16 

Failing Scenarios: 
cucumber features/edit_with_blurbs.feature:6 # Scenario: Article Edit With Blurb 

1 scenario (1 failed) 
6 steps (1 failed, 3 skipped, 2 passed) 
0m1.739s 

` `` ...

+0

Вы уверены, что ссылка «Правка» на самом деле правильно соблюдена? Также есть ли у вас Capybara.default_max_wait_time (default_wait_time, если вы используете Capybara <2.5.0) достаточно долго, чтобы страница редактирования могла завершить загрузку? –

+0

Я редактировал вопрос, чтобы включить полный тестовый результат. Кажется, что отображается страница «Редактирование», но я не уверен, как ее проверить. – user2799827

+1

Есть ли уникальный текст, который будет на странице редактирования? Если так, добавьте проверку для этого перед шагом «заполнить». Еще одна вещь, которую нужно проверить, - это то, что поле действительно видно на странице, это часто бывает проблемой при использовании виджетов JavaScript, которые скрывают реальное поле и отображают другое поле вместо этого, или используют наложенные элементы для полипольного поведения заполнителя и т. Д. –

ответ

0

Если вы уверены, что страница открыта, то вы можете установить поле:

find(:id, "blurb").set("This is my edit summary") 
Смежные вопросы