os系统(mac)下Python+selenium+chromedirver/geckodriver,驱动安装后selenium报错分析。

os系统(mac)下Python+selenium+chromedirver/geckodriver,驱动安装后selenium报错分析。

这里介绍下安装chromedirver/geckodriver后,运行selenium打开网页的代码后报错的解决方法。

chromedirver

  1. 下载与chrome版本相对应的chromedirver版本后依然报版本不匹配错误
    版本对照表可参靠:https://blog.****.net/BinGISer/article/details/88559532;
    下载地址:
    https://npm.taobao.org/mirrors/chromedriver/
  2. 解决方法
    将下chromedirver放到selenium使用的Python包的安装地址中,即放到python.exe的同级文件夹下;
    一般Python.exe所在位置如下:
    os系统(mac)下Python+selenium+chromedirver/geckodriver,驱动安装后selenium报错分析。
    即系统文件usr/local/bin中。
    具体操作步骤:
    1、通过finder直接查看目录,我们先右键(必须开启了右键辅助功能,其他经验上有讲)会弹出个上拉菜单,选择前往文件夹。
    os系统(mac)下Python+selenium+chromedirver/geckodriver,驱动安装后selenium报错分析。
    2、弹出前往文件夹的对话框,填入/usr/local/bin就可以前往了
    os系统(mac)下Python+selenium+chromedirver/geckodriver,驱动安装后selenium报错分析。
    3、直接将下载解压好的chromedirver放到打开的目录下,重新运行打开Chrome浏览器代码,即可解决报错问题。

geckodriver

1、解压安装后报错,运行selenium报错’geckodriver’ executable needs to be in PATH。
2、解决方法:(基本同上)
将geckodriver放到selenium使用的Python包的安装地址中,即放到python.exe的同级文件夹下,即/usr/local/bin中,操作方法如上。放入后重新运行selenium中打开firfox的代码即可解决问题。