Capybara - Chromium司机与Selenium袜子代理不起作用,但恶作剧工作

时间:2017-08-13 04:12:01

标签: ruby capybara chromium socks headless

使用Chromium 62.0.3168.0我已确认在直接运行socks5时使用了我的chrome代理:./chrome --headless --remote-debugging-port=9222 --proxy-server=socks5://127.0.0.1:9055 http://bot.whatismyipaddress.com但是当我尝试通过Capybara时,我收到错误:

SOCKSError::ServerFailure: general SOCKS server failure

如何通过我的袜子代理让Capybara使用headless_chrome

我的Chrome Capybara设置无效:

Capybara.default_driver = :headless_chromium
Capybara.register_driver :headless_chromium do |app|
  Capybara::Selenium::Driver.new(app, {
    browser: :chrome,
    desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
      "chromeOptions" => {
        'binary' => "#{ENV['HOME']}/chromium/src/out/Default/chrome",
        'args' => ["no-sandbox", "disable-gpu", "headless",
                   "proxy-server=socks5://127.0.0.1:9055"]
      }
    )
  })
end

如果我从上面的代码中删除proxy-server arg,:headless_chromium驱动程序可以正常工作,但不使用socks代理。

以下是poltergeist的Capybara设置,它成功使用了socks代理:

Capybara.default_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, {
    :phantomjs => Phantomjs.path,
    :phantomjs_options => ["--proxy-type=socks5", "--proxy=127.0.0.1:9055"]
  })
end

0 个答案:

没有答案