Capybara Poltergeist / PhantomJS测试-在页面上禁用JavaScript [英] Capybara Poltergeist/PhantomJS testing - disable javascript on a page
问题描述
在我的项目中,JavaScript相当密集,因此对于可能在浏览器中禁用Java的用户,我有一个< noscript>
警报。
On of my projects is fairly javascript intensive, so I have a <noscript>
alert for users that might come in with Javascript disable on their browsers.
我正在尝试为我的测试套件编写一个测试来验证这种行为,但是我不知道如何告诉Capybara / Poltergeist(我用于功能介绍)测试)以在发出请求之前禁用javascript。我在文档中找不到任何清晰的内容。
I'm trying to write a test for my test suite that just validates this behavior, but I can't figure out how to tell Capybara/Poltergeist (which I use for my feature tests) to disable javascript before making requests. I can't find anything clear in the documentation. Has anyone else run into something like this?
推荐答案
所以,我仍然不知道如何在Poltergeist中做到这一点,但是我弄清楚了如何在Selenium中进行设置:
So, I still have no idea how to do this in Poltergeist, but I figured out how to get it set up in Selenium:
Capybara.register_driver :selenium_firefox_nojs do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
profile["javascript.enabled"] = false
Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end
这篇关于Capybara Poltergeist / PhantomJS测试-在页面上禁用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!