python-3.x selenium 基gecko驱动程序不是目录错误:

c9qzyr3d  于 2023-01-14  发布在  Python
关注(0)|答案(1)|浏览(152)

我试图让seleniumbase geckodriver(firefox)工作,它似乎告诉我,我的驱动程序文件是一个目录

E   NotADirectoryError: [Errno 20] Not a directory: '/usr/local/lib/python3.8/dist-packages/seleniumbase/drivers/geckodriver'
====================================================== short test summary info =======================================================
ERROR seleniumtest2.py - NotADirectoryError: [Errno 20] Not a directory: '/usr/local/lib/python3.8/dist-packages/seleniumbase/drive...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================== 1 error in 0.19s ==========================================================

我试着只给它目录,它告诉我它需要这个文件。
我怎样才能让壁虎司机在 selenium 基地工作?
代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox('/usr/local/lib/python3.8/dist-packages/seleniumbase/drivers/geckodriver')
#driver = webdriver.Firefox('/usr/bin/geckodriver')
driver.get("https://www.python.org")
print(driver.title)
search_bar = driver.find_element_by_name("q")
search_bar.clear()
search_bar.send_keys("getting started with python")
search_bar.send_keys(Keys.RETURN)
print(driver.current_url)
driver.close()

安装方法:

seleniumbase install geckodriver

以及

apt install firefox-geckodriver

相同的错误,两个驱动程序文件。
更新:
我的两个司机位置

root@Inspiron:# ls -l /usr/bin/geckodriver 
-rwxr-xr-x 1 root root 3476048 Jun  3 10:17 /usr/bin/geckodriver


root@Inspiron:# ls -l /usr/local/lib/python3.8/dist-packages/seleniumbase/drivers/geckodriver
-rwxr-xr-x 1 user user 7008696 Oct 12  2019 /usr/local/lib/python3.8/dist-packages/seleniumbase/drivers/geckodriver
fxnxkyjh

fxnxkyjh1#

尝试使用您的驱动器名称作为路径,对我有效
driver=webdriver.Firefox('C:/usr/local/lib/python3.8/distpackages/seleniumbase/drivers/geckodriver')

相关问题