我正在尝试使用添加了扩展程序的Selenium启动Chrome浏览器。但我得到低于错误。
错误 - 无法从''加载扩展程序。清单文件丢失或不可读。
我的代码:
when "CHROME"
chrome_extensions = []
begin
File.open('/Users/chinmayajb/Downloads/MPM_testing/packages/extension_1_2_4.crx', "rb") do |file|
chrome_extensions << Base64.encode64(file.read.chomp)
puts 'Encoded....'
end
rescue Exception => e
raise "ERROR: Couldn't File.read or Base64.encode64 a Chrome extension: #{e.message}"
end
caps_opts = {'chrome.switches' => chrome_extensions}
chrome_switches = %w[--enable-logging --v=1 --disable-popup-blocking --disable-extensions-file-access-check --always-authorize-plugins --disable-improved-download-protection --allow-file-access --load-extension='caps_opts']
Capybara.register_driver :selenium_chrome do |app|
# Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => capabilities)
Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches => chrome_switches)
# Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches => ["--allow-legacy-extension-manifests--load-extension=/Users/chinmayajb/Downloads/MPM_testing/packages/extension_1_2_4.crx"])
end
Capybara.default_driver = :selenium_chrome
端