HEXUXI
HEXUXI
2017-03-22 07:20

新手--python3.5调用webdriver报错

  • python
  • selenium

脚本启动Fiefox报错
代码:

-*- coding:utf-8 -*-

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http;//www.baidu.com')

browser.find_element_by_id('kw').send_keys('selenium')
browser.find_element_by_id('su').click()

browser.quit()

报错信息:
Traceback (most recent call last):
File "C:\Users\hxx\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\hxx\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 676, in init
restore_signals, start_new_session)
File "C:\Users\hxx\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 955, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:/workspace/baidu.py", line 3, in
browser = webdriver.Firefox()
File "C:\Users\hxx\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 145, in init
self.service.start()
File "C:\Users\hxx\AppData\Local\Programs\Python\Python35\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.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答