Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python-selenium.common.exceptions.WebDriverException:消息:未知错误_Python_Python 3.x_Selenium - Fatal编程技术网

python-selenium.common.exceptions.WebDriverException:消息:未知错误

python-selenium.common.exceptions.WebDriverException:消息:未知错误,python,python-3.x,selenium,Python,Python 3.x,Selenium,我熟悉python 3.8和selenium,但最近我下载了最新的edge web驱动程序zip文件,并从中运行mswdedriver.exe,并在ide中键入以下代码: from selenium import webdriver browser = webdriver.Edge('‪F:\za\python\Assistant\msedgedriver.exe') browser.maximize_window() browser.get(url='http://seleniumhq.or

我熟悉python 3.8和selenium,但最近我下载了最新的edge web驱动程序zip文件,并从中运行mswdedriver.exe,并在ide中键入以下代码:

from selenium import webdriver

browser = webdriver.Edge('‪F:\za\python\Assistant\msedgedriver.exe')
browser.maximize_window()
browser.get(url='http://seleniumhq.org/')
但我看到了这个错误:

selenium.common.exceptions.WebDriverException: Message: 'MicrosoftEdgeDriver' executable needs to be 
in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687
朋友们,你能帮我吗?
提前感谢。

加载webdriver时,您需要提供webdriver可执行文件的路径,或者将其存储为环境变量:

webdriver.Edge(可执行文件\u path=“path/to/executable”)
web驱动程序本质上是一种特殊的浏览器应用程序,您必须先安装该应用程序,然后才能使用它运行任何操作

这是Edge的web驱动程序。或者您可以使用错误消息中的链接


下面是一个类似的问题

根据Python语法,需要转义可执行路径中的反斜杠:

browser = webdriver.Edge('‪F:\\za\\python\\Assistant\\msedgedriver.exe')

如果您不知道如何将其添加到环境变量中,这里已经给出了答案:如果您完成这些步骤,您的代码将按原样工作,但是,如果您想将可执行文件作为答案添加到
webdriver.Edge
中,但将路径设置为
F:\za\python\Assistant\msedgedriver.exe
我仍然会看到以下错误
selenium.common.exceptions.WebDriverException:消息:“msedgedriver.exe”可执行文件需要在路径中。请从http://go.microsoft.com/fwlink/?LinkId=619687
您能否编辑原始帖子以反映您的代码更改?更新了代码