[FIX] script selenium: support snap firefox for Ubuntu

This commit is contained in:
Mathieu Benoit 2026-02-05 12:26:29 -05:00
parent 621670e7c9
commit 273763a4fb

View file

@ -13,6 +13,7 @@ import sys
import tempfile import tempfile
import time import time
import tkinter as tk import tkinter as tk
from pathlib import Path
from tkinter import filedialog from tkinter import filedialog
from pykeepass import PyKeePass from pykeepass import PyKeePass
@ -226,10 +227,16 @@ class SeleniumLib(object):
self.config.firefox_binary_path self.config.firefox_binary_path
) )
elif not self.config.use_network: elif not self.config.use_network:
status_location = subprocess.check_output( # test snap firefox for Ubuntu first
["which", "firefox"], text=True snap_firefox_path = "/snap/bin/firefox"
).strip() firefox_path_exist = Path(snap_firefox_path).exists()
firefox_options.binary_location = status_location if firefox_path_exist:
firefox_options.binary_location = snap_firefox_path
else:
status_location = subprocess.check_output(
["which", "firefox"], text=True
).strip()
firefox_options.binary_location = status_location
firefox_profile = webdriver.FirefoxProfile() firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference( firefox_profile.set_preference(