问题
I am using this code in 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")
Unlucky, this open Firefox but not the URL (not return any error). Do you know why?
回答1:
If you are using Selenium 3.x
along with the recent Frirefox Quantum
browsers, you have to download geckodriver.exe
from this location place it in your system and mention the absolute location of the geckodriver
binary through the argument executable_path
as follows:
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()
来源:https://stackoverflow.com/questions/48045412/webdriver-geturl-open-firefox-but-not-the-url