Ruby on rails rspec特性测试未找到模态输入

Ruby on rails rspec特性测试未找到模态输入,ruby-on-rails,rspec,capybara,Ruby On Rails,Rspec,Capybara,我有一个rspec测试,它试图在弹出模式表单中填充一个字段。相关线路为 fill_in 'Name', with: 'Jo Blo' 错误消息是 Capybara::ElementNotFound: Unable to find visible field "Name" that is not disabled 这意味着它正在查找字段,但将其视为已禁用。但是,如果在出现故障时使用capybara屏幕截图查看页面,则该字段可见,并且该字段的html为 <div class=

我有一个rspec测试,它试图在弹出模式表单中填充一个字段。相关线路为

fill_in 'Name', with: 'Jo Blo'
错误消息是

Capybara::ElementNotFound:
       Unable to find visible field "Name" that is not disabled
这意味着它正在查找字段,但将其视为已禁用。但是,如果在出现故障时使用capybara屏幕截图查看页面,则该字段可见,并且该字段的html为

<div class="field">
        <label for="user_name">Name</label><sup>*</sup><br>
        <input type="text" name="user[name]" id="user_name">
</div>
错误消息变为

    Failure/Error: expect(page).to have_css '#modal_new_user'
           expected to find visible css "#modal_new_user" but there were no 

matches. Also found "", which matched the selector but not all filters.
这似乎意味着找不到模式,但再次,如果我查看水豚的屏幕截图,模式的html是可见的。 我该如何解决这个问题

我使用的是capybara 3.0.2和rspec rails 3.7.2

引导模式的代码是

 <div id='modal_new_user' class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">Warning</h4>
          <p>enter code here Right now there is a 10 day free trial. Just fill in the form below.</p>
      </div>
      <div class="modal-body">
    <form class="edit_user" id="edit_user_12004" action="/users" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="306T/5kB9pqb9sW6mdW+tXyCzfydEF2tf8wQMJXEICO5uQ/YEDVVYqg12l7Qe+lU4uELZy/d1VIhzZObk/FVcQ==" />

      <div class="field">
        <label for="user_name">Name</label><sup>*</sup><br />
        <input type="text" name="user[name]" id="user_name" />
      </div>
      <div class="field">
        <label for="user_email">Email</label><sup>*</sup><br />
        <input type="email" name="user[email]" id="user_email" />
      </div>
      <div class="field">
        <label for="user_password">Password</label><sup>*</sup><br />
        <input type="password" name="user[password]" id="user_password" />
      </div>

      <p id="terms">By creating your account, you are agreeing to the site <a target="_blank" href="/legal">Terms and Conditions</a>.  You will not be spammed, we dislike spam as much as you do.
      </p>
      <input type="hidden" value="clubs#edit" name="user[referral]" id="user_referral" />
      <div class="actions">
      <input type="submit" name="commit" value="Join Now" class="btn btn-cta btn-cta-primary" data-disable-with="Join Now" />
      </div>
</form>  </div>
  <div class="modal-footer right_close_button">
      <button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
  </div>
</div>

&时代;
警告
在这里输入代码现在有一个10天的免费试用。只需填写下表

名称*
电子邮件*
密码*

创建您的帐户即表示您同意该网站。你不会被垃圾邮件,我们和你一样不喜欢垃圾邮件。

接近
结果是测试有
type::system
,所以当我删除它时,测试通过了。如果puma.rb指定了并发性,那么rails系统测试似乎会出现问题。

实际包含的HTML是什么?“找不到可见字段”名称“未禁用”并不意味着is看到字段“名称”,而是意味着它已禁用,这意味着它要么没有看到字段,要么确实看到字段,但它已禁用-对错误的理解不要超过它的状态。这可能是一个时间问题。你必须记住,水豚开始以极快的速度点击东西,这通常是在JS完成之前。尝试使用
find('#modal_new_user')。在('Name',中填入:'Jo Blo')
,因为这将等待元素出现。@max
fill_in
本身也将等待匹配的元素(最长为Capybara.default_max_wait_time seconds),因为它实现为
find(…)。set(…)
我有Capybara.default\u max\u wait\u time=5。我已经为模式添加了代码。
 <div id='modal_new_user' class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">Warning</h4>
          <p>enter code here Right now there is a 10 day free trial. Just fill in the form below.</p>
      </div>
      <div class="modal-body">
    <form class="edit_user" id="edit_user_12004" action="/users" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="306T/5kB9pqb9sW6mdW+tXyCzfydEF2tf8wQMJXEICO5uQ/YEDVVYqg12l7Qe+lU4uELZy/d1VIhzZObk/FVcQ==" />

      <div class="field">
        <label for="user_name">Name</label><sup>*</sup><br />
        <input type="text" name="user[name]" id="user_name" />
      </div>
      <div class="field">
        <label for="user_email">Email</label><sup>*</sup><br />
        <input type="email" name="user[email]" id="user_email" />
      </div>
      <div class="field">
        <label for="user_password">Password</label><sup>*</sup><br />
        <input type="password" name="user[password]" id="user_password" />
      </div>

      <p id="terms">By creating your account, you are agreeing to the site <a target="_blank" href="/legal">Terms and Conditions</a>.  You will not be spammed, we dislike spam as much as you do.
      </p>
      <input type="hidden" value="clubs#edit" name="user[referral]" id="user_referral" />
      <div class="actions">
      <input type="submit" name="commit" value="Join Now" class="btn btn-cta btn-cta-primary" data-disable-with="Join Now" />
      </div>
</form>  </div>
  <div class="modal-footer right_close_button">
      <button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
  </div>
</div>