如何在ruby中使用selenium web驱动加载自定义chrome扩展?

时间:2016-12-26 09:36:10

标签: ruby selenium-webdriver google-chrome-extension selenium-chromedriver

当我执行selenium web driver时,有没有办法加载自定义chrome扩展名(实际上是js文件的文件夹)?

1 个答案:

答案 0 :(得分:3)

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :chrome, 
  :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome({
    'chromeOptions' => {
      'extensions' => [
        Base64.strict_encode64(File.open('/Users/user/Downloads/hallway_extension.crx', 'rb').read)
      ]
    }
  })