Selenium使用中的SSL错误

测试的时候出现ERROR:ssl_client_socket_impl.cc(924)错误导致测试要等待浏览器超时,所以速度极慢,具体错误如下:

[568:23192:0414/170633.452:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170648.867:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170704.468:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170719.884:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
.[568:23192:0414/170735.347:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170750.766:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170806.365:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170807.080:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100
[568:23192:0414/170821.781:ERROR:ssl_client_socket_impl.cc(924)] handshake failed; returned -1, SSL error code 1, net_error -100

解决办法

给Chrome的Options加 --ignore-ssl-error 参数,忽略掉 ssl 错误,代码如下:

options = ChromeOptions()
options.add_argument('--ignore-ssl-error')  # 忽略ssl错误
self.driver = webdriver.Chrome(options=options)

版权声明:
作者:Sunrise
链接:https://www.qlm.life/?p=244
来源:迷迭记录
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>