gpt4 book ai didi

python - Linux 上缺少 Selenium Firefox 配置文件

转载 作者:太空宇宙 更新时间:2023-11-04 09:33:02 26 4
gpt4 key购买 nike

我正在尝试让 Selenium 在 Ubuntu 虚拟机上运行。我有一个赫克的时间这样做。无论我做什么,我总是得到以下对话:

Profile Missing

我不需要特别使用任何配置文件。我最初认为 Selenium\Gecko 为其实例创建了一个临时配置文件。以下是我尝试过的所有内容。此外,我还尝试以 sudo 身份运行,\或将配置文件的所有权设置为 nobody 以及将配置文件目录的权限设置为 777。这些都没有结果。我看过其他关于此的 SO 帖子,但没有一个能为我提供任何导致答案的信息,这显然是我来这里的原因。

# create a new Firefox session
# binary = FirefoxBinary('/snap/bin/firefox')
# binary = FirefoxBinary('/usr/local/bin/geckodriver')
profile = webdriver.FirefoxProfile(profile_directory='/home/jaberwocky/snap/firefox/common/.mozilla/firefox/tm4nraze.selenium')
# profile.set_preference("browser.download.folderList",2)
# profile.set_preference("browser.download.manager.showWhenStarting",False)
# profile.set_preference("browser.download.dir", os.getcwd())
# profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
driver = webdriver.Firefox(firefox_profile=profile)
driver.implicitly_wait(20)
driver.get(base_url)

python_button = driver.find_element_by_class_name('sh-hide')
python_button.click()

Selenium 版本 3.141.0

Firefox 版本 65.0.2

Python版本 3.7.2

Linux 发行版 Ubuntu Budgie 18.04.2 LTS

enter image description here

关于这个问题的信息确实不多。我在这里做错了什么?

更新:我为每次执行 gecko 找到了一个日志文件。这是它显示的内容:

ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
/snap/firefox/185/bin/desktop-launch: line 174: /home/addohm/snap/firefox/common/.config/user-dirs.dirs: No such file or directory
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
cp: cannot create regular file '/home/addohm/snap/firefox/common/.config/': Not a directory
/snap/firefox/185/bin/desktop-launch: line 177: /home/addohm/snap/firefox/common/.config/user-dirs.dirs.md5sum: No such file or directory
/snap/firefox/185/bin/desktop-launch: line 177: /home/addohm/snap/firefox/common/.config/user-dirs.locale.md5sum: No such file or directory
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
1551441977454 mozrunner::runner INFO Running command: "/snap/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.kvmA0GU2ZdrC"
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
/snap/firefox/185/bin/desktop-launch: line 174: /home/addohm/snap/firefox/common/.config/user-dirs.dirs: No such file or directory
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
cp: cannot create regular file '/home/addohm/snap/firefox/common/.config/': Not a directory
/snap/firefox/185/bin/desktop-launch: line 177: /home/addohm/snap/firefox/common/.config/user-dirs.dirs.md5sum: No such file or directory
/snap/firefox/185/bin/desktop-launch: line 177: /home/addohm/snap/firefox/common/.config/user-dirs.locale.md5sum: No such file or directory
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/lib/$LIB/liblsp.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"

(firefox:27487): Gtk-WARNING **: Error loading theme icon 'dialog-warning' for stock: Icon 'dialog-warning' not present in theme Pocillo

没有 ~/snap/firefox/common/.config/ 但有 ~/snap/firefox/current/.config/

最佳答案

这个问题似乎与使用 Snap 而不是 apt 安装 Firefox 直接相关。

引用:https://ubuntuforums.org/showthread.php?t=2398478

它一开始就工作,没有特定的配置文件。

不幸的是,如果您使用内置软件包管理器安装 Firefox,它将通过 snap 安装。所以请小心并安装:

sudo apt install firefox

关于python - Linux 上缺少 Selenium Firefox 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54941970/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com