I am trying to use selenium in pycharm to open firefox. I Have no idea what the problem is.
-I have installed geckodriver in the correct PATH. (/usr/local/bin) -I am using pop_os 20.04 LTS
when I run
from selenium import webdriver
driver = webdriver.Chrome(r'/usr/local/bin')
*Traceback (most recent call last):
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/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: '/usr/local/bin': '/usr/local/bin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/elliot/PycharmProjects/IG/igbot.py", line 3, in <module>
driver = webdriver.Chrome(r'/usr/local/bin')
File "/home/elliot/PycharmProjects/IG/venv/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/elliot/PycharmProjects/IG/venv/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: 'bin' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1*
GeckoDriver is used to control Firefox and you are trying to use Chrome
driver = webdriver.Chrome(...
# ^^^^^^ ???
Either use ChromeDriver or switch to Firefox.
Passing r'/usr/local/bin'
to Chrome
constructor makes no sense, you can omit it assuming GeckoDriver or ChromeDriver can be found in PATH
.
There is a nice library to automate tedious task of drivers management, see webdriver-manager.
Try going through "Installation" and "Getting Started" chapters of selenium-python docs.