Answer the question
In order to leave comments, you need to log in
Selenium doesn't see the driver specified in webdriver.Firefox()?
Good afternoon,
I have already used selenium several times, but at the moment I don’t understand what I missed, I downloaded the necessary driver for Firefox, put it in the selenium_driver directory next to the script, below I will give an example script
#!/usr/bin/env python3
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path=r'/var/www/html/parsers/selenium_driver/geckodriver')
driver.get("https://www.python.org")
bash-5.0# file /var/www/html/parsers/selenium_driver/geckodriver
/var/www/html/parsers/selenium_driver/geckodriver: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.26, BuildID[sha1]=32c4cfc2d9346336dc7c20e99a62df9be344d609, with debug_info, not stripped
bash-5.0# ./selenium_get.py
Traceback (most recent call last):
File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/root/.pyenv/versions/3.7.3/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/root/.pyenv/versions/3.7.3/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/var/www/html/parsers/selenium_driver/geckodriver': '/var/www/html/parsers/selenium_driver/geckodriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./selenium_get.py", line 6, in <module>
driver = webdriver.Firefox(executable_path=r'/var/www/html/parsers/selenium_driver/geckodriver')
File "/root/.pyenv/versions/3.7.3/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/root/.pyenv/versions/3.7.3/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: 'geckodriver' executable needs to be in PATH.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question