Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load firefox in selenium webdriver in python

I have installed Python 3.6.2, Selenium 3.5.0 with GeckoDriver 0.18.0 and the firefox version is 54.0.1version on windows 7. I am trying to run a selenium script which is loading a firefox where i get mismatch with firefox version error. Please let me know what is the issue. The code and error message below.

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")

Error message returned:

Traceback (most recent call last):
  File "C:\PythonSelenium\Sample.py", line 12, in <module>
    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.
like image 853
Rashmi G Avatar asked Aug 15 '17 12:08

Rashmi G


People also ask

How do I run Firefox in selenium Python?

To make Firefox work with Python selenium, you need to install the geckodriver. The geckodriver driver will start the real firefox browser and supports Javascript. Take a look at the selenium firefox code. First import the webdriver, then make it start firefox.

Which version of Firefox is compatible with selenium?

Selenium users must update to version 3.11 or later to use geckodriver.

Why it is Gecko driver for Firefox?

The term Gecko stands for a Web Browser engine that is inbuilt within Mozilla Firefox browser. Gecko driver acts as a proxy between Web Driver enabled clients(Eclipse, Netbeans, etc.) and Mozilla Firefox browser. In short, Gecko driver acts as a link between Selenium Web Driver tests and Mozilla Firefox browser.


1 Answers

When you work with Python 3.6.2, Selenium 3.5.0 with GeckoDriver 0.18.0 and the Firefox browser version is 54.0.1 on Windows 7, you can't set the property marionette to False. Forcefully setting marionette to False will raise an WebDriverException. So either you have to accept the default setting of ["marionette"] = True or you can explicitly set ["marionette"] to True as follows:

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")
like image 83
undetected Selenium Avatar answered Sep 30 '22 13:09

undetected Selenium