KiY*_*ter 5 python selenium google-chrome headless selenium-webdriver
我想从 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
Run Code Online (Sandbox Code Playgroud)
看来你已经很接近了。根据文档,--allow-insecure-localhost应以以下内容开头--:
options.add_argument('--allow-insecure-localhost')
Run Code Online (Sandbox Code Playgroud)
--allow-insecure-localhost: 允许忽略本地主机上的 TLS/SSL 错误(无间隙,无请求阻塞)
| 归档时间: |
|
| 查看次数: |
6985 次 |
| 最近记录: |