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

隐身守侯 提交于 2019-12-10 17:57:32

问题


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

selenium: 3.12.0, Python:3.6.5

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

回答1:


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



来源:https://stackoverflow.com/questions/50838882/how-to-enable-an-allow-insecure-localhost-flag-in-chrome-from-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!