Reputation: 13
This is the error I keep getting. I have searched google multiple times trying to figure this issue out. I have added msedgedriver.exe to the PATH several times in a few different locations on my pc. I followed this: How to open up Microsoft Edge using Selenium and Python
This is what I am trying to run.
from selenium import webdriver
driver = webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
driver.get('edge://settings/help')
print("Page title is: %s" %(driver.title))
#driver.quit()
this is the error:
from selenium import webdriver
>>>
>>> driver = webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
Traceback (most recent call last):
File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, 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 "<stdin>", line 1, in <module>
File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 56, in __init__
self.edge_service.start()
File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'msedgedriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687
Please someone help. lol this is driving me nuts. Thank you :)
Removing r from
driver =webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
Upvotes: 1
Views: 4741
Reputation: 453
Downloading the webdriver manually has always led to problems... unless of course you are very careful in your methods. Here's an alternative... use the webdriver_manager library (https://pypi.org/project/webdriver-manager/) to download and handle the driver by itself.
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from webdriver_manager.chrome import ChromeDriverManager
edge = webdriver.Edge(EdgeChromiumDriverManager().install())
chrome = webdriver.Chrome(ChromeDriverManager().install())
I would also recommend you to use the chromedriver rather than the edgedriver since chrome is more robust and well tuned for such applications.
Upvotes: 1