I am trying to open Firefox with this simple program in python, I am using the latest version of Ubuntu.
from selenium import webdriver
brow = webdriver.Firefox()
But I am getting the error message,
"selenium.common.exceptions.SessionNotCreatedException: Message: Failed to start browser /snap/firefox/current/firefox.launcher: no such file or directory"
I have tried updating firefox and using a different geckodriver.
2
Answers
Surely you should take a good look at the paths you enter, however, i recommend a generic approach.
You can use a webdriver-manager that takes care of any problems in this respect automatically and in any supported operating system
N.B.: this is compatible with Selenium 4.x and below.
The error is most likely a bug in GeckoDriver causing it to try to find Firefox inside Snap instead of the default location
/usr/bin/firefox
, because the script has been run from PyCharm that was installed through Snap.To solve the issue, you have to unset the Snap environment variables before running the script. Actually, I found out that only two variables must be unset:
SNAP_NAME
andSNAP_INSTANCE_NAME
: