【发布时间】:2017-01-27 19:02:26
【问题描述】:
我将我的项目推送到 heroku,之后,我的 capybara-tests 停止工作。我想,问题在于 rake assets:precompile,因为这似乎是唯一的命令,它会以某种方式影响我的本地代码。
虽然我的测试按预期工作,但现在每个测试都返回相同的错误:
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').
首先,我想,为了让测试再次工作,我运行 rake assets:clean 来删除资产。但错误仍然存在。
然后,我删除了包含资产的公共文件。但错误保持不变。
有谁知道,我该如何解决这个问题?
编辑 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:
一位评论员要求截图,这里是:
评论者是对的,问题似乎不在于 rake assets:precompile,而在于另一个。感谢您的提示! (不过我想知道,为什么 rake assets:precompile 会影响 capybara 中的屏幕大小。
【问题讨论】:
-
很好奇。我会让 Capybara/Poltergeist 写一些截图来看看它“看到”了什么。
-
如果您使用have setup the assets pipeline on heroku correctly,则不必运行
rake assets:precompile。 Heroku 将在提交后挂钩中执行此操作——这是一种更好的解决方案,可以消除您忘记编译资产的错误部署,并减少 git 历史记录的流失。 -
@Wukerplank 你能写一个答案,我可以接受吗?谢谢你的建议。还是我应该删除我的问题?
-
@Metaphysiker 很高兴我能帮上忙!我在下面发布了我的答案。