菜鸟求帮助selenium+Python运行报错

woshidevil_1983 2017-02-26 04:54:05
# coding=utf-8
from selenium import webdriver
driver=webdriver.Firefox()
driver.get("http://www.baidu.com")
driver.find_element_by_id("kw").sendkeys("Selenium2")
driver.find_element_by_id("su").click()

运行报以下错误,找不到指定文件?求解应如何处理
C:\Python34\python.exe "C:/Documents and Settings/Administrator/PycharmProjects/study/baidu.py"
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "C:\Python34\lib\subprocess.py", line 1114, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Documents and Settings/Administrator/PycharmProjects/study/baidu.py", line 4, in <module>
driver=webdriver.Firefox()
File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 140, in __init__
self.service.start()
File "C:\Python34\lib\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.

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00BEF850>>
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", line 173, in __del__
self.stop()
File "C:\Python34\lib\site-packages\selenium\webdriver\common\service.py", line 145, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
...全文
1118 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
melancholy_419 2017-04-24
  • 打赏
  • 举报
回复
去下载一个geckodriver.exe,然后放在你python.exe同目录下就OK了,这个是你selenium和火狐版本不兼容
土著零 2017-03-21
  • 打赏
  • 举报
回复
解决了吗老哥,我也遇到这个问题...

5,227

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 质量管理/软件测试
功能测试压力测试安全性测试 个人社区 湖南省·长沙市
社区管理员
  • 软件测试
  • 虫无涯
  • 小博测试成长之路
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

欢迎大家加入到软件测试的社区,在这里,希望大家勇于发表自己的看法,欢迎大家分享自己在软件测试工作过程中遇到的问题以及工作经验分享。

1.想转行的小伙伴,遇到问题没有及时回复的,可以私聊小博进行反馈

2.大家对社区有好的建议,都可以在社区发帖进行反馈

推荐大家学习的软件测试入门笔记:软件测试入门学习笔记

试试用AI创作助手写篇文章吧