学习selenium过程中总会遇到各种各样的问题
今天后台一直循环运行RPA的时候,发现了输出了好多这样的error
解决方法:
这是由于不安全的地址错误,循环报错,导致程序终止。在配置chromedriver的时候在chrome_options中添加一个–ignore-certificate-errors参数,忽略掉证书错误,如下:
# 配置chromedriver s = Service(executable_path='C:\Program Files\Google\Chrome\Application\chromedriver.exe') chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--ignore-certificate-errors') # 忽略证书错误 driver = webdriver.Chrome(service=s, options=chrome_options)
DevTools listening on ws://127.0.0.1:49842/devtools/browser/6428a4e5-3d56-4b15-b894-795b1b4aaab0 [8132:7552:0518/093030.553:ERROR:device_event_log_impl.cc(214)] [09:30:30.553] Bluetooth: bluetooth_adapter_winrt.cc:1075 Getting Default Adapter failed.
不停的提示,虽然不影响程序的运行,可是看到这些乱七八糟的就烦… 搜了一下, 找到这两个输出的抑制方法:
# 配置chromedriver s = Service(executable_path='C:\Program Files\Google\Chrome\Application\chromedriver.exe') chrome_options = webdriver.ChromeOptions() # 忽略证书错误 chrome_options.add_argument('--ignore-certificate-errors') # 忽略 Bluetooth: bluetooth_adapter_winrt.cc:1075 Getting Default Adapter failed. 错误 chrome_options.add_experimental_option('excludeSwitches', ['enable-automation']) # 忽略 DevTools listening on ws://127.0.0.1... 提示 chrome_options.add_experimental_option('excludeSwitches', ['enable-logging']) driver = webdriver.Chrome(service=s, executable_path='<path-to-chrome>', options=chrome_options)
记录备忘.
3 Comments
我的有这两个参数 还是报这样的错
@maryhu52 对于不同的浏览器需要添加不同的参数, 可以参考以下内容做一下尝试:
1、对于Chrome,您需要添加 -ignore-certificate-errors 和-ignore-ssl-errors ChromeOptions()参数:
2、对于Firefox,您需要将 accept_untrusted_certs 设置为True:
3、对于Internet Explorer,您需要设置 acceptSslCerts 所需的功能:
@风影OvO 太贊了,感謝博主,解決了項目上遇到的問題