python - 如何从 selenium 在 Chrome 中启用 "allow-insecure-localhost"标志?

标签 python google-chrome selenium selenium-webdriver headless

我想从 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 : Enables TLS/SSL errors on localhost to be ignored (no interstitial, no blocking of requests)

关于python - 如何从 selenium 在 Chrome 中启用 "allow-insecure-localhost"标志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50838882/

相关文章:

javascript - 如果很少发生,我可以使用哪些工具来找出 JavaScript 挂起网页的原因?

selenium - Google Chrome 窗口大小调整限制

python - seaborn:带有背景颜色的图例

HTML5 Canvas 弧在 Google Chrome 中无法正确呈现

python - python中列表的本质,为什么我得到一个重复列表?

javascript - Google Chrome 上的大文件下载问题

python - 需要使用 selenium webdriver 和 python 单击 xpath

selenium - 在 Chrome、IE 和 Opera 上处理 SSL 证书的问题

python - 在 GUI 界面 Tkinter Python 中打印输出

python - 实现一个完整的 Python Unix 风格的守护进程