Home > Software design >  Python linuxmint binary is not a Firefox executable
Python linuxmint binary is not a Firefox executable

Time:08-30

I test selenium python and I have these errors with firefox and I can't find the solution Here my code

from selenium import webdriver 
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
options = Options()
options.binary = FirefoxBinary(r'/usr/bin/firefox')

driver = webdriver.Firefox(executable_path= r'./scrap/geckodriver', options=options) 
driver.get("http://www.google.com") 
print (driver.page_source.encode('utf-8') )
driver.close() 

My error message python linuxmint :

selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

I've been searching the forum for a few days, but I can't find a solution for linux mint !!

Thank you Stéphane

CodePudding user response:

This is an example of working selenium/Firefox setup on Debian, which should also work on Mint, given it's essentially the same os:

from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options as Firefox_Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import time as t
import pandas as pd

firefox_options = Firefox_Options()

# firefox_options.add_argument("--width=1280")
# firefox_options.add_argument("--height=720")

driverService = Service('chromedriver/geckodriver') ## path where you saved geckodriver

browser = webdriver.Firefox(service=driverService, options=firefox_options)

Selenium docs: https://www.selenium.dev/documentation/

CodePudding user response:

Now I get this error

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH

Thank you Stéphnae

  • Related