目录

在 microsoft-edge-dev 上设置 Python selenium


Get Correct Version

1
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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

https://i.loli.net/2021/10/09/xneYFgATV6P75Hm.png