This minimal example works just fine using standard python3 but it will not run in PyCharm project.
from selenium import webdriver
browser = webdriver.Firefox(executable_path="PATHTODRIVER")
browser.get('https://www.google.com')
The error shown in PyCharm is:
selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
so it is not finding binary location, which I have tried specifying.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.binary_location = "/usr/bin/firefox"
browser = webdriver.Firefox(firefox_options=options, executable_path="PATHTODRIVER")
browser.get('https://www.google.com')
The new error was
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
I do not understand the error well, so I stopped digging further. The code simply runs well using
python3 test.py
why it doesn't work under PyCharm project environment?