python - geckodriver

查看:195
本文介绍了python - geckodriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

macOS selenium3.4 python3 sublimetext3

web开发测试驱动方法 第四页 第一个功能测试

functional_tests.py

from selenium import webdriver 

browser = webdriver.Firefox()

browser.get('http://localhost:8000')

assert 'Django' in browser.title

报错

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 74, in start

stdout=self.log_file, stderr=self.log_file)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in init

restore_signals, start_new_session)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1333, in _execute_child

raise child_exception_type(errno_num, err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/Frankyan360/Documents/web_test/functional_tests.py", line 3, in <module>

browser = webdriver.Firefox()

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 142, in init

self.service.start()

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 81, in start

os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

[Finished in 0.2s with exit code 1]
[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]

不知道哪里出问题了

解决方案

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

这篇关于python - geckodriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆