【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>> ignoredpython

下载geckodriver,下不到的到个人以前的文章里有连接。web

Windows用户固然是加这个东西到path环境变量里,python2.7

Mac用户看你们都遇到这个问题了,没解决,测试

把这个geckodriver放在某个位置,而后ui

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 来源:知乎 著做权归做者全部,转载请联系做者得到受权。
相关文章
相关标签/搜索