<p>我同意RichEdwards提出的建议</p>
<p>我建议试着检查以下几点可能会帮助您缩小范围并解决问题</p>
<ol>
<li><p>确保您使用的是正确版本的web驱动程序。检查浏览器版本并从<a href="https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/" rel="nofollow noreferrer">here</a>下载相应的驱动程序。如果可以使用最新稳定版本的MS Edge浏览器进行测试,效果会更好</p>
</li>
<li><p>确保已使用下面的命令安装MS Edge Selenium工具</p>
</li>
</ol>
<blockquote>
<p>pip install msedge-selenium-tools selenium==3.141</p>
</blockquote>
<p>示例代码:</p>
<pre><code>from msedge.selenium_tools import Edge, EdgeOptions
options = EdgeOptions()
options.use_chromium = True
options.add_argument("-inprivate")
options.binary_location = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
driver = Edge(executable_path = r"D:\<driver path>\msedgedriver.exe", options = options) # Modify the path here...
# Navigate to URL
driver.get("https://example.com")
# Access web elements
driver.find_element_by_id('fname').send_keys("ABC")
driver.find_element_by_id('lname').send_keys("XYZ")
driver.quit
</code></pre>
<p>输出:</p>
<p><a href="https://i.stack.imgur.com/0mQE1.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0mQE1.gif" alt="enter image description here"/></a></p>