我在 Python 中使用此代码:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)
driver.get("www.google.com")
不幸的是,这打开了 Firefox,但没有打开 URL(不返回任何错误)。 你知道为什么吗?
最佳答案
如果您使用 Selenium 3.x
以及最新的 Frirefox Quantum
浏览器,则必须从 this location 下载 geckodriver.exe
将其放入您的系统中,并通过参数 executable_path
提及 geckodriver
二进制文件的绝对位置,如下所示:
from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
关于python - Webdriver.get(url) 打开 Firefox 但不打开 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48045412/