selenium.common.exceptions.WebDriverException: Message: 'MicrosoftWebDriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687
源码:
from selenium import webdriver
import time, json
import os
import unittest
import pandas as pd
class yangli_test(unittest.TestCase):
def setUp(self):
#option = webdriver.ChromeOptions()
#self.driver = webdriver.Chrome(chrome_options=option) #chrome浏览器
self.driver = webdriver.Edge() #Edge浏览器 win10
self.driver.implicitly_wait(10)
self.driver.maximize_window()
self.url = "https://www.baidu.com/"
def test_open_baidu_url(self):
self.driver.get(self.url)
time.sleep(10)
self.driver.quit()
if __name__ == "__main__":
unittest.main()
解决方案:
1. 查看Microsoft Edge版本

2.下载对应的Microsoft Edge Driver
网址:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
3.下载完成后解压,把msedgedriver.exe拷贝一份重命名为MicrosoftWebDriver.exe,并把它们两个拷贝到Python安装目录下:

本文介绍了在Python自动化测试中遇到的`selenium.common.exceptions.WebDriverException`错误,该错误提示'MicrosoftWebDriver.exe'可执行文件需要在PATH路径中。解决方案包括检查MicrosoftEdge版本,下载对应版本的MicrosoftEdgeDriver,并将其复制到Python安装目录下,确保正确运行Edge浏览器自动化测试。

被折叠的 条评论
为什么被折叠?



