python3+msedgedriver用新版msedge進行chrome-handless測試

首先下載驅動 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/web

而後解壓,把解壓後的文件夾添加進環境變量pathless

而後安裝兩個包:ui

pip install msedge-selenium-tools selenium

 而後就能夠了:google

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()
相關文章
相關標籤/搜索