Chromedriver开关--disable-popup-blocking在无头模式下使用Ruby无效 [英] Chromedriver switches --disable-popup-blocking Doesn't Work Using Ruby in Headless Mode

查看:56
本文介绍了Chromedriver开关--disable-popup-blocking在无头模式下使用Ruby无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ruby中像这样启动chromedriver

I start my chromedriver like this in Ruby

driver = Watir::Browser.new :chrome, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate --disable-notifications --start-maximized]

但是,当我开始使用如下所示的无头模式时,它什么也不会返回.

But, when I start using headless mode like below, it returns nothing.

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

我需要开关-disable-popup-blocking ,以防止我尝试访问的网站上出现允许位置"弹出窗口.如果chrome不能从无头开始,则可以使用.但这在无头模式下不起作用.有什么办法可以使它起作用?

I need the switch --disable-popup-blocking in order to prevent the "Allow Location" popup on the website I am trying to access. It works if the chrome doesn't start in headless. But it doesn't work in headless mode. Is there any way to make it works?

谢谢.

推荐答案

无头模式当前不支持Chrome偏好设置.请参见此Chromium Bug

Chrome Preferences are not currently supported in Headless Mode. See Comment 7 in this Chromium Bug

这篇关于Chromedriver开关--disable-popup-blocking在无头模式下使用Ruby无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆