Rails,Capybara:测试在 rake assets:precompile 后不再工作
Rails, Capybara: Tests not working anymore after rake assets:precompile
我将我的项目推送到 heroku 之后,我的 capybara-tests 停止工作。我想,问题出在 rake assets:precompile,因为这似乎是唯一的命令,它以某种方式影响了我的本地代码。
虽然我的测试按预期工作,但现在每个测试 returns 都出现相同的错误:
Capybara::Poltergeist::MouseEventFailed:
Firing a click at co-ordinates [91.5, 69.5] failed. Poltergeist
detected another element with CSS selector 'html body.container article.ng-scope div.ng-scope nav-bar.ng-scope nav.navbar.navbar-fixed-top.navbar-inverse div.container-fluid div#bs-example-navbar-collapse-2.collapse.navbar-collapse' at this position.
It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
首先,我想,为了让测试再次工作,我 运行 耙 assets:clean 删除资产。但错误依然存在。
然后,我删除了包含资产的 public 文件。但是错误还是一样。
有谁知道,我该如何解决这个问题?
编辑 1:
这是我的一项测试的示例:
scenario "User adds a comment" do
anotheruser = User.create!(email: "anotheruser@gmail.com",
password: "abcdefgh123",
password_confirmation: "abcdefgh123")
argumentation = Argumentation.create(title: "Metaphysik und Natur", content: "Man könnte meinen, Metaphysik und Naturwissenschaften haben etwas gemeinsam.", user_id: anotheruser.id)
argument = Argument.create(title: "Naturwissenschaft als Fortsetzung der Metaphysik", content:"Es gibt Leute, die sagen, Wissenschaft ist die Beantwortung von metaphysischen Fragen.", argumentation_id: argumentation.id, place: 1)
log_in(email, password)
visit "/argumentation#!/" + argumentation.id.to_s
fill_in "argumentcommenttitle", with: "Das ist mein Kommentar dazu!"
fill_in "argumentcomment", with: "Die Argumentation ist gültig, doch sind die Prämissen falsch"
click_button "Kommentar erstellen"
expect(page).to have_content("Das ist mein Kommentar dazu!")
expect(page).to have_content("Die Argumentation ist gültig, doch sind die Prämissen falsch")
end
编辑 2:
有评论者要截图,这里是:
评论者是对的,问题似乎不是关于抽成 assets:precompile,而是另一个。感谢您的提示! (虽然我想知道,为什么 rake assets:precompile 会影响水豚的屏幕大小。
错误日志中的这一行让我很好奇:
It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
我建议 Capybara/Poltergeist 拍几张截图看看是什么 "sees"。
我将我的项目推送到 heroku 之后,我的 capybara-tests 停止工作。我想,问题出在 rake assets:precompile,因为这似乎是唯一的命令,它以某种方式影响了我的本地代码。
虽然我的测试按预期工作,但现在每个测试 returns 都出现相同的错误:
Capybara::Poltergeist::MouseEventFailed:
Firing a click at co-ordinates [91.5, 69.5] failed. Poltergeist
detected another element with CSS selector 'html body.container article.ng-scope div.ng-scope nav-bar.ng-scope nav.navbar.navbar-fixed-top.navbar-inverse div.container-fluid div#bs-example-navbar-collapse-2.collapse.navbar-collapse' at this position.
It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
首先,我想,为了让测试再次工作,我 运行 耙 assets:clean 删除资产。但错误依然存在。
然后,我删除了包含资产的 public 文件。但是错误还是一样。
有谁知道,我该如何解决这个问题?
编辑 1:
这是我的一项测试的示例:
scenario "User adds a comment" do
anotheruser = User.create!(email: "anotheruser@gmail.com",
password: "abcdefgh123",
password_confirmation: "abcdefgh123")
argumentation = Argumentation.create(title: "Metaphysik und Natur", content: "Man könnte meinen, Metaphysik und Naturwissenschaften haben etwas gemeinsam.", user_id: anotheruser.id)
argument = Argument.create(title: "Naturwissenschaft als Fortsetzung der Metaphysik", content:"Es gibt Leute, die sagen, Wissenschaft ist die Beantwortung von metaphysischen Fragen.", argumentation_id: argumentation.id, place: 1)
log_in(email, password)
visit "/argumentation#!/" + argumentation.id.to_s
fill_in "argumentcommenttitle", with: "Das ist mein Kommentar dazu!"
fill_in "argumentcomment", with: "Die Argumentation ist gültig, doch sind die Prämissen falsch"
click_button "Kommentar erstellen"
expect(page).to have_content("Das ist mein Kommentar dazu!")
expect(page).to have_content("Die Argumentation ist gültig, doch sind die Prämissen falsch")
end
编辑 2:
有评论者要截图,这里是:
评论者是对的,问题似乎不是关于抽成 assets:precompile,而是另一个。感谢您的提示! (虽然我想知道,为什么 rake assets:precompile 会影响水豚的屏幕大小。
错误日志中的这一行让我很好奇:
It may be overlapping the element you are trying to interact with. If you don't care about overlapping elements, try using node.trigger('click').
我建议 Capybara/Poltergeist 拍几张截图看看是什么 "sees"。