When running integration tests using Capybara and Cucumber, I encountered a scenario where JavaScript needed to be disabled. While I can manually disable JS in Chrome developer tools, I am looking for a way to automate this process. Is there an option to start a browser up with JS disabled or enable/disable it during the test?
Capybara.register_driver :chrome do |app|
chrome_binary = ENV["HENDRICKS_CHROME_BINARY"]
if chrome_binary.nil?
Capybara::Selenium::Driver.new(app, :browser => :chrome)
else
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
"chromeOptions" => {
"binary" => chrome_binary + "/Contents/MacOS/Chromium"
}
)
Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => capabilities)
end
end
Is there a way to achieve this with Chrome as my browser?