python3+msedgedriver用新版msedge进行chrome-handless测试

首先下载驱动 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

然后解压,把解压后的文件夹添加进环境变量path

然后安装两个包:

pip install msedge-selenium-tools selenium

然后就可以了:

from msedge.selenium_tools import Edge, EdgeOptions

options = EdgeOptions()
options.use_chromium = True
options.binary_location = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
options.add_argument("headless")
options.add_argument("disable-gpu")
browser = Edge(options = options)
browser.get('https://www.google.com')
browser.save_screenshot('google.png')
print('done') 

browser.quit()
(0)

相关推荐