繁体   English   中英

如何在selenium中启用Chrome中的“allow-insecure-localhost”标志?

[英]How to enable an “allow-insecure-localhost” flag in Chrome from selenium?

我想从selenium启用“allow-insecure-localhost”标志。
我怎么能这样做?

selenium:3.12.0,Python: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 :允许忽略localhost上的TLS / SSL错误(无插页式,不阻止请求)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM