I can't understand why geckodriver doesn't work and why the path doesn't exist. I use Ubuntu and Firefox, I uninstalled and reinstalled geckodriver and Firefox-geckodriver. I checked the version and I use geckodriver 0.30.0 (d372710b98a6 2021-09-16 10:29 +0300). I have already tried uninstalling and installing with
wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
tar -xvzf geckodriver-v0.30.0- linux64.tar.gz
chmod + x geckodriver
export PATH = $ PATH: / path-to-extracted-file /
I also installed
sudo apt install firefox-geckodriver
I try to run this little script, but I get the error:
raise WebDriverException (
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Code
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
import os
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
profile_path = '/home/jack/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default'
options=Options()
options.set_preference('profile', profile_path)
options.set_preference('network.proxy.type', 1)
options.set_preference('network.proxy.socks', '127.0.0.1')
options.set_preference('network.proxy.socks_port', 9050)
options.set_preference("network.proxy.socks_remote_dns", False)
service = Service('/usr/bin/geckodriver')
driver = Firefox(service=service, options=options)
driver.get("www.google.com")
driver.quit()
PATHit has to be path to folder withgeckodriver-/usr/bin, not path to filegeckodriver-/usr/bin/geckodriver. I have onPATHfolder in my home/home/furas/binand in this folder I put all needed programs or scripts (in Python, Perl, Ruby, etc)PATHin.bashrcso it would set it everytime when you restart computergeckodriverin folder/home/furas/bin/and when I useService('/home/furas/bin/geckodriver')then it works. Maybe you don't havegeckodriverin folder/usr/bin/but in different folder - maybe full path is/usr/bin/geckodriver/geckodriveror maybe you put file in home folder. You should first check if you can run/usr/bin/geckodriver --versionin console/terminal to see version.