Capybara Poltergeist/PhantomJS testing - disable javascript on a page

送分小仙女□ 提交于 2019-12-08 01:59:29

问题


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.

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?


回答1:


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 


来源:https://stackoverflow.com/questions/18109776/capybara-poltergeist-phantomjs-testing-disable-javascript-on-a-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!