4

我将登录表单放入 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

我正在将我的新页面和编辑页面呈现到表单部分。Newedit按钮都有打开JqueryUI:remote => true对话框的方法。谢谢..

4

2 回答 2

1

尝试这个

 describe "with valid information" do
    before do
      fill_in "username text-input-field-id", :with => "user@example.com"
      ...
      ...
    end
于 2012-11-27T08:15:39.017 回答
0

正如 Dipak 建议的那样,用字段的 id 替换或使用全部小写。有时Username不仅仅是username水豚看到了……或者确切地说是 Seleminum。

于 2013-01-20T00:53:15.750 回答