I've just started building my first bot and I'm struggling with the first step: automating a browser.
Here's my code:
from selenium import webdriver
browser = webdriver.Firefox(executable_path="/Users/ker/Downloads/geckodriver")
browser.get("https://app.finxter.com/")
When I try running the code I get the following error:
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
I've installed the geckodriver unix executable and specified the path, but for some reason it still won't work and I can't really understand the error message.
CodePudding user response:
You may get this error message for two reasons:
- Firefox isn't installed in your system.
- Firefox isn't installed in the default location within your system.
Solution:
If Firefox isn't installed, install it on your system.
If firefox isn't installed at the default location, you need to pass the path of the firefox executable through an
Option()
instance:
from selenium import webdriver from selenium.webdriver.firefox.options import Options
options = Options()
options.binary_location = r"C:/location/firefox.exe"
driver = webdriver.Firefox(options=options, executable_path="/Users/ker/Downloads/geckodriver.exe")
driver.get('https://app.finxter.com/')
CodePudding user response:
Please check if your driver is executable you can change the permission with the command below.
chmod x /Users/ker/Downloads/geckodriver