python - 使用selenium模块控制浏览器

时间:2016-11-14 17:35:17

标签: selenium selenium-webdriver python-3.5 selenium-firefoxdriver

我安装了python版本3.5.2,selenium版本3.0.1和firefox版本49.0.2。

完成所有这些并在我的shell脚本中输入

    >>> from selenium import webdriver
    >>> browser = webdriver.Firefox()

并收到如下错误: 有人可以指导我这里有什么问题。 我很感激。我刚刚开始使用python。感谢

#
Traceback (most recent call last):
  File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    browser = webdriver.Firefox()
  File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
    self.service.start()
  File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\site-packages\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. 
#

0 个答案:

没有答案