尝试创建webdriver并出现错误

时间:2020-09-27 23:09:14

标签: python selenium webdriver

我正在尝试创建Firefox WebDriver,但使用时在python中收到以下错误消息

from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
driver.get('http://inventwithpython.com')

我收到以下错误:

C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\python.exe "C:/Users/Kyle/PycharmProjects/pythonProject/Datafolks/smoke tests.py"
Traceback (most recent call last):
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
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 "C:/Users/Kyle/PycharmProjects/pythonProject/Datafolks/smoke tests.py", line 2, in <module>
    driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Users\Kyle\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver.exe' executable needs to be in PATH. 


Process finished with exit code 1

0 个答案:

没有答案