本文介绍了如何启用"allow-insecure-localhost"在Chrome中从硒中标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从硒中启用"allow-insecure-localhost"标志.
我该怎么办?

I want to enable "allow-insecure-localhost" flag from selenium.
How I can do it?

硒:3.12.0,Python:3.6.5

selenium: 3.12.0, Python:3.6.5

Chrome驱动程序创建代码:

Chrome driver creation code:

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 应由--取代,如下所示:

Seems you were pretty close. As per the documentation --allow-insecure-localhost should be precceded by -- as follows:

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

这篇关于如何启用"allow-insecure-localhost"在Chrome中从硒中标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 01:12