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安装目录下: