如何在 Chrome 中启用Selenium的"allow-insecure-localhost"标志?



我想从硒启用"允许不安全的本地主机"标志。
我该怎么做?

硒: 3.12.0, 蟒蛇:3.6.5

Chrome 驱动程序创建代码:

def create_driver():
options = Options()
if sys.platform == "darwin":
options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
options.add_experimental_option("detach", True)
options.add_argument('allow-insecure-localhost') # I tried to be enable, but it does not affect to chrome.
if sys.platform == "win32":
chromedriver_path = r".chromedriver"
else:
chromedriver_path = "../chromedriver"
driver = webdriver.Chrome(chromedriver_path, chrome_options=options)
return driver

看来你们很接近。根据文档--allow-insecure-localhost前面应按如下方式--

options.add_argument('--allow-insecure-localhost')

--allow-insecure-localhost:允许忽略本地主机上的 TLS/SSL 错误(无插页式广告,无阻止请求(

相关内容

最新更新