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
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 ie .exe
. Effectively, you code block will be:
driver = Firefox(executable_path='/path/to/geckodriver', options=options)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.