/在 microsoft-edge-dev 上设置 Python selenium

Created Fri, 26 Mar 2021 21:43:35 +0800 Modified Fri, 09 Aug 2024 13:25:47 +0000
73 Words 0 min

Get Correct Version

microsoft-edge-dev --version

The output is Microsoft Edge 91.0.831.1 dev in my case.

Get Corresponding WebDriver

Find the corresponding version at msedgewebdriverstorage and download the zip.

Extract it to you path like /usr/local/bin or $HOME/.local/bin.

Write Code

Following is a example.

from msedge.selenium_tools import EdgeOptions, Edge

options = EdgeOptions()
options.use_chromium = True
options.binary_location = r"/usr/bin/microsoft-edge-dev"
options.set_capability("platform", "LINUX")

webdriver_path = r"/home/ayamir/.local/bin/msedgewebdriver"

browser = Edge(options=options, executable_path=webdriver_path)
browser.get("http://localhost:8000")

assert "Django" in browser.title

Launch it

img