[英]Open edge browser with selenium. Path error
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.
我已经在我的电脑上的几个不同位置多次将 msedgedriver.exe 添加到 PATH 中。 I followed this: How to open up Microsoft Edge using Selenium and Python
我跟着这个: 如何使用 Selenium 和 Python 打开 Microsoft Edge
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移除 r
driver =webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
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.
这是另一种选择……使用 webdriver_manager 库( https://pypi.org/project/webdriver-manager/ )自行下载和处理驱动程序。
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from webdriver_manager 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.我还建议您使用 chromedriver 而不是 edgedriver,因为 chrome 更健壮并且针对此类应用程序进行了很好的调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.