简体   繁体   English

使用 selenium 打开边缘浏览器。 路径错误

[英]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.

相关问题 Headless Edge Selenium 错误:没有打开浏览器 - Headless Edge Selenium Error: No browser is open 硒。 轮播中数据的 x 路径 - selenium. x path for data in carousel 使用Selenium在python中查找损坏的链接。 没有提供的架构错误 - Find broken links in python with Selenium. No supplied schema error 自动点击带有 Selenium 的按钮。错误引发 TimeoutException - Automatic click on button with Selenium. Error raise TimeoutException Selenium.NoSuchElementException - Selenium. NoSuchElementException Selenium 不打开下拉按钮。 Html 元素名称正确,但有问题 - Pull-down buttons do not open with Selenium. Html element name correct, but something is wrong 使用 selenium 打开 Tor 浏览器 - Open tor browser with selenium 硒。 上传一个新的chrome打开文件上的文件(或者如何在python上模拟ctrl + v) - Selenium. Upload a file on a new chrome open file pop up (or how to simulate ctrl+v on python) Python,Selenium。 成功初始化 webdriver 但无法打开 web 页面,因为“没有名为 get 的属性” - Python, Selenium. Successfully initialized webdriver but couldn't open a web page because “there is no attribute called get” Python Selenium。 元素不可交互 - Python Selenium. Element is not interactable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM