• 博客园Logo
  • 会员
  • 周边
  • 捐助
  • 新闻
  • 博问
  • 闪存
  • 赞助商
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 简洁模式 ... 退出登录
    注册 登录
金大鑫要坚持
博客园    首页    新随笔    联系   管理    订阅  订阅

【selenium 3】 Mac 下测试环境搭建 Firefox 47+ gecko driver Mac

错误代码如下:
File "/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 65, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f753ad53390>> ignored

下载geckodriver,下不到的到我的之前的文章里有链接。

Windows用户当然是加这个东西到path环境变量里,

Mac用户看大家都遇到这个问题了,没解决,

把这个geckodriver放在某个位置,然后

from selenium import webdriver
import time
dr = webdriver.Firefox(executable_path = '/Users/jinwenxin/desktop/pythonPractice/geckodriver')
time.sleep(5)
print 'Browser will close.'
dr.quit()
print 'Browser is close'
教大家一个方法,我用了在python下执行了help(webdriver.Firefox) 回车,这样就知道了传什么参数。
大家好,我就是月薪只有八千的三年测试经验的人。
不过这只是暂时的。加油!
未来,有戏!

作者:金二哥 我就是金二哥。
链接:https://www.zhihu.com/question/49568096/answer/127226689
来源:知乎
著作权归作者所有,转载请联系作者获得授权。
posted @ 2016-10-18 21:40  金大鑫要坚持  阅读(7751)  评论(0)  编辑  收藏  举报
会员力量,点亮园子希望
刷新页面返回顶部
Copyright © 2024 金大鑫要坚持
Powered by .NET 8.0 on Kubernetes