Ruby on rails 测试设备-Capybara::ElementNotFound:找不到xpath“/html";
我正试图用RSpec、水豚和Factory Girl测试我网站的登录功能。我总是在终端中遇到以下错误,但找不到任何解决方案。当我使用Ruby on rails 测试设备-Capybara::ElementNotFound:找不到xpath“/html";,ruby-on-rails,rspec,capybara,factory-bot,Ruby On Rails,Rspec,Capybara,Factory Bot,我正试图用RSpec、水豚和Factory Girl测试我网站的登录功能。我总是在终端中遇到以下错误,但找不到任何解决方案。当我使用save\u并打开页面时会得到一个空白页面。我希望有人知道怎么了。谢谢 这是测试输出 Failure/Error: expect(page).to have_text("Login successful.") Capybara::ElementNotFound: Unable to find xpath "/html" # ./sp
save\u并打开页面时
会得到一个空白页面。我希望有人知道怎么了。谢谢
这是测试输出
Failure/Error: expect(page).to have_text("Login successful.")
Capybara::ElementNotFound:
Unable to find xpath "/html"
# ./spec/features/navigation_spec.rb:49:in `block (2 levels) in <top (required)>'
这是我的factory\u girl.rb
文件
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
FactoryGirl.define do
factory :normal_user, class: User do
firstname "John"
lastname "Doe"
email "test@user.com"
password "thepassword"
admin false
end
end
以及factories.rb
文件
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
FactoryGirl.define do
factory :normal_user, class: User do
firstname "John"
lastname "Doe"
email "test@user.com"
password "thepassword"
admin false
end
end
事实证明,我必须在
登录后手动访问路径
,以查看附加的登录页面内容。尝试使用have\u内容而不是have\u文本…不确定这不会解决问题。我在其他地方也成功地使用了have_文本。似乎login_as方法没有任何重定向“影响”。