selenium遇到的问题

来源:互联网 发布:如何判断存在sql注入 编辑:程序博客网 时间:2024/05/02 05:56
  1. chrome报错:“您使用的是不受支持的命令行标记:–ignore-certificete-errors。稳定性和安全性会有所下降。”

    • 解决办法:添加以下代码
      # options = webdriver.ChromeOptions()# options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])# self.driver = webdriver.Chrome(chrome_driver_path, chrome_options=options)
  2. firefox报错:Message: ‘geckodriver’ executable needs to be in PATH.

    • 下载geckodriver.exe
      • [geckodriver下载地址]
    • 添加geckodriver.exe路径到系统变量Path
      • ;C:\Program Files (x86)\Mozilla Firefox
  3. firefox报错:Message: Unable to find a matching set of capabilities

    • 本地配置:
      • selenium版本:3.4.1
      • firefox版本:53.0.3
      • geckodriver版本:0.16.1
    • 报错原因:
      • geckodriver对高版本firefox支持不友好
      • 官方解释:https://github.com/mozilla/geckodriver#supported-firefoxen
    • 解决办法:
      • 卸载新版本
      • 安装ver 52.0.2
  4. chrome报错:ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

    • 原因:chromedriver与chrome浏览器版本不匹配
    • 原配置:
      • chromedriver.exe版本:v2.9
      • chrome浏览器版本: 58.0.3029.110 (64-bit)
      • selenium版本:3.4.1
      • python版本:3.6.1
    • 解决办法:
      • 下载v2.24版本的chromedriver.exe替换原有的chromedriver.exe
原创粉丝点击