美文网首页
Mac下安装Python-Selenium

Mac下安装Python-Selenium

作者: Lutous | 来源:发表于2017-12-13 17:27 被阅读9次

Python3.7

geckodriver

selenium3.8

Lee小白也是最近才开始接触Python和Selenium,选择Python的时候毫不犹豫的选最新版本。至于安装PyCharm,Python,百度一大堆,不做赘述。

在安装selenium的时候  Python3需使用 pip3 install selenium 也可以 sudo easy_install selenium 后者默认安装最新版本。

geckodriver 下载解压后放到/usr/local/bin目录下

执行一下以下代码:

from selenium import webdriver

import time

dr=webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')

time.sleep(5)

print('Browser will be closed')

dr.quit()

print('Browser is close')


如果遇到

raise WebDriverException("Can not connect to the Service %s"% self.path) selenium.common.exceptions.WebDriverException: Message: Cannot connect to the Service geckodriver

需要查看一下你的hosts文件是否存在及127.0.0.1是否指向localhost

相关文章

网友评论

      本文标题:Mac下安装Python-Selenium

      本文链接:https://www.haomeiwen.com/subject/wclzixtx.html