Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Capybara::ElementNotFound:用于jquery ui对话框内容_Ruby On Rails_Ruby_Ruby On Rails 3_Rspec_Rspec Rails - Fatal编程技术网

Ruby on rails Capybara::ElementNotFound:用于jquery ui对话框内容

Ruby on rails Capybara::ElementNotFound:用于jquery ui对话框内容,ruby-on-rails,ruby,ruby-on-rails-3,rspec,rspec-rails,Ruby On Rails,Ruby,Ruby On Rails 3,Rspec,Rspec Rails,我将我的登录表单放入Jquery UI对话框弹出框中。当我开始做RSpec测试时,我的 Failure/Error: fill_in "Username", with: "user@example.com" Capybara::ElementNotFound cannot fill in, no text field, text area or password field with id, name, or label 'Username' found 这是我的规格/要求页面: descri

我将我的登录表单放入Jquery UI对话框弹出框中。当我开始做RSpec测试时,我的

Failure/Error: fill_in "Username", with: "user@example.com"
Capybara::ElementNotFound
cannot fill in, no text field, text area or password field with id, name, or label 'Username' found
这是我的规格/要求页面:

describe "create user", :js => true do

  before { visit new_enr_rds_dea_path }

  let(:submit) { "Create Dea" }

  describe "with invalid information" do
    it "should not create a user" do
      expect { click_button submit }.not_to change(Enr::Rds::Dea, :count)
    end
  end

  describe "with valid information" do
    before do
      fill_in "Username", with: "user@example.com"
      fill_in "Password", with: "foobar"
      fill_in "Confirm password", with: "foobar"
      fill_in "Organisation", with: "foobar"
    end

    it "should create a user" do
      expect { click_link_or_button submit }.to change(Enr::Rds::Dea, :count).by()
    end
  end
工厂.rb

FactoryGirl.define do
  factory :dea_user do |user|
    user.dea_user             "example@in4systems.com"
    user.dea_pwd              "foobar"
    user.dea_pwd_confirmation "foobar"
    user.pro_organisation_id  "NHER"
  end
end
我正在将我的新页面和编辑页面呈现为部分表单。
New
edit
按钮都具有打开JqueryUI对话框的
:remote=>true
方法。谢谢。

试试这个

 describe "with valid information" do
    before do
      fill_in "username text-input-field-id", :with => "user@example.com"
      ...
      ...
    end

按照Dipak的建议,替换为字段的id,或者使用所有小写字母。有时水豚看到的不是
Username
,而是
Username
。。。或者准确地说是Seleminum。

您使用的是哪种水豚驱动程序?确保它支持javascript。最新版本的Capybara显然已经被修改,如果找不到确切的元素,就会抛出错误。这可能是问题的一部分……我知道这听起来像是一个通用的答案,但我建议使用
launchy
(这是一个非常方便的宝石)和
save\u and\u open\u page
填写“用户名”之前,使用:user@example.com“