Unable to load firefox in selenium webdriver in python

2024/10/7 22:20:14

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_browserself._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.
Answer

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 FirefoxBinarycapabilities = 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")
https://en.xdnf.cn/q/70194.html

Related Q&A

Plot hyperplane Linear SVM python

I am trying to plot the hyperplane for the model I trained with LinearSVC and sklearn. Note that I am working with natural languages; before fitting the model I extracted features with CountVectorizer …

Calculating plugin dependencies

I have the need to create a plugin system that will have dependency support and Im not sure the best way to account for dependencies. The plugins will all be subclassed from a base class, each with i…

Vectorization: Not a valid collection

I wanna vectorize a txt file containing my training corpus for the OneClassSVM classifier. For that Im using CountVectorizer from the scikit-learn library. Heres below my code: def file_to_corpse(file…

Solve a simple packing combination with dependencies

This is not a homework question, but something that came up from a project I am working on. The picture above is a packing configuration of a set of boxes, where A,B,C,D is on the first layer and E,F,G…

ImportError: cannot import name FFProbe

I cant get the ffprobe package to work in Python 3.6. I installed it using pip, but when I type import ffprobe it saysTraceback (most recent call last): File "<stdin>", line 1, in <m…

Generate larger synthetic dataset based on a smaller dataset in Python

I have a dataset with 21000 rows (data samples) and 102 columns (features). I would like to have a larger synthetic dataset generated based on the current dataset, say with 100000 rows, so I can use it…

Executing python script in android terminal emulator

I installed python 2.7 in my Android device and I tried executing a python script by typing the command in terminal emulator. The problem is that although I use the full path for python the following e…

How to return error messages in JSON with Bottle HTTPError?

I have a bottle server that returns HTTPErrors as such:return HTTPError(400, "Object already exists with that name")When I receive this response in the browser, Id like to be able to pick out…

Cant execute msg (and other) Windows commands via subprocess

I have been having some problems with subprocess.call(), subprocess.run(), subprocess.Popen(), os.system(), (and other functions to run command prompt commands) as I cant seem to get the msg command to…

Django development server stops after logging into admin

I have installed django 3.0 in python 3.7 and started a basic django project. I have created a superuser and run the development server using python manage.py runserver. When I go to localhost:8000/adm…