【问题标题】:How to enable an "allow-insecure-localhost" flag in Chrome from selenium?如何从 selenium 在 Chrome 中启用“allow-insecure-localhost”标志?
【发布时间】:2018-11-23 03:11:46
【问题描述】:

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

硒: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

标签: python google-chrome selenium selenium-webdriver headless


【解决方案1】:

看来你已经很接近了。根据文档--allow-insecure-localhost 应以-- 开头,如下所示:

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

--allow-insecure-localhost:允许忽略 localhost 上的 TLS/SSL 错误(无插页式广告,无阻塞请求)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    • 2021-09-07
    • 2013-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多