1

I have problem with set up my program in freebsd. I try use geckodriver. I try 32 bit and 64 bit, download link is here https://github.com/mozilla/geckodriver/releases

Documentation link

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode

My code

from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support import expected_conditions as expected
from selenium.webdriver.support.wait import WebDriverWait

options = Options()
options.add_argument('-headless')
driver = Firefox(executable_path=r"usr\home\myuserName\geckodriver.exe", options=options)
driver.get("https://www.verivox.de/stromvergleich/vergleich/#/?plz=10555&persons=on&usage=3500&bonus=OnlyCompliant&profile=H0&product=electricity&source=1&q=WzYsMCwxLDEsMSwxLDEsMiwyMCwwLDEsNzQxMTIyLCI3MTA4NSIs>
allheader=WebDriverWait(driver,20).until(expected.visibility_of_all_elements_located((By.CSS_SELECTOR,"li[class='result-item'] .result-name-area>.result-name")))
for header in allheader:
     print("Header: " + header.text)

I get error

Traceback (most recent call last):
  File "/home/myuserName/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/local/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'usr\\home\\myuserName\\geckodriver.exe': 'usr\\home\\myuserName\\geckodriver.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "skriptas.py", line 10, in <module>
    driver = Firefox(executable_path=r"usr\home\myuserName\geckodriver.exe", options=options)
  File "/home/myuserName/.local/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
    self.service.start()
  File "/home/myuserName/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'usr\home\myuserName\geckodriver.exe' executable needs to be in PATH.

I try change link like this

driver = Firefox(executable_path="usr\home\myuserName\geckodriver.exe", options=options)

or like this

driver = Firefox(executable_path='usr\home\myuserName\geckodriver.exe', options=options)

or like this

driver = Firefox(executable_path=r'usr/home/myuserName/geckodriver.exe', options=options)

but still same error. Please help me, all help will be appreciated

Kalakutas
  • 124
  • 2
  • 15

1 Answers1

1

As you are using Selenium in freebsd environment you need to use the GeckoDriver untaring either of the following from mozilla / geckodriver page:

  • geckodriver-v0.28.0-linux32.tar.gz
  • geckodriver-v0.28.0-linux64.tar.gz

Additionally, while passing the absolute path of the GeckoDriver you need to drop the extension part i.e. .exe. Effectively, you code block will be:

driver = Firefox(executable_path='/path/to/geckodriver', options=options)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • need but in ```geckodriver-v0.28.0-linux32.tar.gz``` in the folder or extract exe? if just exe still not working with same error – Kalakutas Nov 23 '20 at 12:35
  • @Kalakutas Extract the exe – undetected Selenium Nov 23 '20 at 12:38
  • ```os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable may have wrong permissions``` what to do next? – Kalakutas Nov 23 '20 at 12:40
  • @Kalakutas Your initial issue of _...'usr\home\myuserName\geckodriver.exe' executable needs to be in PATH..._ seems to have got resolved now. `'geckodriver' executable may have wrong permissions` sounds like a new issue. Can you raise a new question as per your new requirement please? Stackoverflow contributors will be happy to help you out. – undetected Selenium Nov 23 '20 at 12:43