Chromedriver 开关 --disable-popup-blocking 在无头模式下使用 Ruby 不起作用

Chromedriver switches --disable-popup-blocking Doesn't Work Using Ruby in Headless Mode

我在 Ruby

中像这样启动我的 chrome 驱动程序
driver = Watir::Browser.new :chrome, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate --disable-notifications --start-maximized]

但是,当我像下面这样开始使用无头模式时,returns 什么都没有。

driver = Watir::Browser.new :chrome, :switches => %W[--ignore-certificate-errors --disable-popup-blocking --disable-translate --disable-notifications --disable-gpu --headless]

我需要开关 --disable-popup-blocking 以防止在我尝试访问的网站上出现 "Allow Location" 弹出窗口。如果 chrome 不是无头启动,它就可以工作。但它在无头模式下不起作用。有什么办法让它起作用吗?

提前致谢。

Chrome Headless 模式目前不支持首选项。请参阅 this Chromium Bug

中的评论 7