猿问

geckodriver

macOSselenium3.4python3sublimetext3
web开发测试驱动方法第四页第一个功能测试
functional_tests.py
fromseleniumimportwebdriver
browser=webdriver.Firefox()
browser.get('http://localhost:8000')
assert'Django'inbrowser.title
报错
Traceback(mostrecentcalllast):File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py",line74,instart
stdout=self.log_file,stderr=self.log_file)
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py",line707,ininit
restore_signals,start_new_session)
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py",line1333,in_execute_child
raisechild_exception_type(errno_num,err_msg)
FileNotFoundError:[Errno2]Nosuchfileordirectory:'geckodriver'
Duringhandlingoftheaboveexception,anotherexceptionoccurred:
Traceback(mostrecentcalllast):File"/Users/Frankyan360/Documents/web_test/functional_tests.py",line3,in
browser=webdriver.Firefox()
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py",line142,ininit
self.service.start()
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py",line81,instart
os.path.basename(self.path),self.start_error_message)
selenium.common.exceptions.WebDriverException:Message:'geckodriver'executableneedstobeinPATH.
[Finishedin0.2swithexitcode1][cmd:['/usr/local/bin/python3','-u','/Users/Frankyan360/Documents/web_test/functional_tests.py']][dir:/Users/Frankyan360/Documents/web_test][path:/usr/bin:/bin:/usr/sbin:/sbin]
不知道哪里出问题了
至尊宝的传说
浏览 629回答 2
2回答

慕森卡

'geckodriver'executableneedstobeinPATH.是说你这个东西应该有个可执行的程序,要添加到PATH里,就是要把geckodriver的位置添加到系统环境变量里,或者你在usr/bin下建立一个软连接

神不在的星期二

首先先确定你selenium的版本,2.53.0之前直接安装selenium是没有问题的,另外再看下你Firefox的版本,在版本45之后会使用新的geckodriver驱动才能使用。最好使用最新版本的selenium以便减少错误。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答