用于无头镀铬的watir中的setDownloadBehavior

时间:2018-01-16 13:13:44

标签: ruby google-chrome watir

chrome中的无头模式不支持文件下载。在issue here下提出了各种解决方案。

硒的解决方案来自该页面,评论78.

def enable_chrome_headless_downloads(driver, directory)
  bridge = driver.send(:bridge)
  path = '/session/:session_id/chromium/send_command'
  path[':session_id'] = bridge.session_id
  bridge.http.call(:post, path, {
  "cmd" => "Page.setDownloadBehavior",
  "params" => {
    "behavior" => "allow",
    "downloadPath" => directory,
  }
})
end

但这不适用于watir。如何在使用watir时实现相同的解决方案。

0 个答案:

没有答案