擅长:python、mysql、java
<p>我认为您的代码本身没有任何重大错误</p>
<blockquote>
<p>It is to be noted that the current Selenium-Python binding is unstable with geckodriver and looks to be Architecture specific. You can find the github <a href="https://github.com/SeleniumHQ/selenium/issues/3884" rel="nofollow noreferrer">discussion</a> and <a href="https://github.com/mozilla/geckodriver/pull/685" rel="nofollow noreferrer">merge</a> here. So you may additionally need to pass the absolute path of the firefox binary as <code>firefox_binary</code> argument while initializing the <strong>webdriver</strong></p>
</blockquote>
<p>以下是您自己的代码,其中有一个简单的调整可以打开Mozilla Firefox浏览器:</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
if __name__ == '__main__':
binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\\path\\to\\geckodriver.exe")
</code></pre>