No se puede cargar Firefox en Selenium Webdriver en Python

He instalado Python 3.6.2, Selenium 3.5.0 con GeckoDriver 0.18.0 y la versión de Firefox es 54.0.1version en Windows 7. Estoy tratando de ejecutar un script de selenium que está cargando un Firefox donde no coincido con la versión de Firefox. . Por favor, hágamelo saber cuál es el problema. El código y el mensaje de error a continuación.

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.firefox.firefox_binary import FirefoxBinary capabilities = webdriver.DesiredCapabilities().FIREFOX capabilities["marionette"] = False binary = FirefoxBinary('C:/Users/gopalakrishnarr/Downloads/FirefoxPortable/App/Firefox/firefox.exe') driver = webdriver.Firefox(firefox_binary=binary, capabilities=capabilities, executable_path="C:/Users/gopalakrishnarr/AppData/Local/Programs/geckodriver-v0.18.0-win64/geckodriver.exe") driver.get("http://www.google.com") 

Mensaje de error devuelto:

 Traceback (most recent call last): File "C:\PythonSelenium\Sample.py", line 12, in  driver = webdriver.Firefox(firefox_binary=binary, capabilities=capabilities, executable_path="C:/Users/gopalakrishnarr/AppData/Local/Programs/geckodriver-v0.18.0-win64/geckodriver.exe") File "C:\Users\gopalakrishnarr\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.5.0-py3.6.egg\selenium\webdriver\firefox\webdriver.py", line 171, in __init__ self.binary, timeout) File "C:\Users\gopalakrishnarr\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.5.0-py3.6.egg\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__ self.binary.launch_browser(self.profile, timeout=timeout) File "C:\Users\gopalakrishnarr\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.5.0-py3.6.egg\selenium\webdriver\firefox\firefox_binary.py", line 73, in launch_browser self._wait_until_connectable(timeout=timeout) File "C:\Users\gopalakrishnarr\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium-3.5.0-py3.6.egg\selenium\webdriver\firefox\firefox_binary.py", line 114, in _wait_until_connectable % (self.profile.path)) selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Possible firefox version mismatch. You must use GeckoDriver instead for Firefox 48+. Profile Dir: C:\Users\GOPALA~1\AppData\Local\Temp\tmpc1dfsd6w If you specified a log_file in the FirefoxBinary constructor, check it for details. 

Cuando trabajas con Python 3.6.2 , Selenium 3.5.0 con GeckoDriver 0.18.0 y la versión del navegador Firefox es 54.0.1 en Windows 7 , no puedes establecer la marionette propiedades en False . Al establecer con fuerza la marionette en False generará una WebDriverException . Por lo tanto, debe aceptar la configuración predeterminada de ["marionette"] = True o puede establecer explícitamente ["marionette"] en True siguiente manera:

 from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary capabilities = webdriver.DesiredCapabilities().FIREFOX capabilities["marionette"] = True binary = FirefoxBinary('C:/Program Files/Mozilla Firefox/firefox.exe') driver = webdriver.Firefox(firefox_binary=binary, capabilities=capabilities, executable_path="C:/Utility/BrowserDrivers/geckodriver.exe") driver.get("http://www.google.com")