-1

我正在尝试运行一个 selenium 脚本,但它无法检测到 chromedriver 任何人都可以在我尝试运行它时帮我解决这个问题,它给了我一个错误,指出 chromedriver 不存在于特定路径中但是我已经下载并将其保留在下面的特定路径是快照和代码以供参考。 在此处输入图像描述

预订.py

import booking.constants as const
from selenium import webdriver


class Booking(webdriver.Chrome):
    def __init__(self , driver_path = "C:\\chromedriver.exe"):
        self.driver_path = driver_path
        super(Booking, self).__init__()

    
    def land_first_page(self):
        self.get(const.BASE_URL)

run.py //在我的编辑器中运行这个python文件

from booking.booking import Booking

inst = Booking()
inst.land_first_page()
4

3 回答 3

1

尝试插入chromedriver所在位置的整个方向路径,也不要忘记使用双斜杠,“C:\Users\desktop\...”整个路径。

编辑 去寻找你正在使用的谷歌浏览器的版本,然后检查你的chromedriver的版本,如果它们不一样那就是错误,尝试安装你的google chrome版本的相同chromedriver版本

于 2021-10-31T19:13:15.160 回答
1

复制 Chromedriver.exe 文件并粘贴您的 CODE 目录

然后

import booking.constants as const
from selenium import webdriver

class Booking(webdriver.Chrome):
    def __init__(self , driver_path = "chromedriver.exe"):
        self.driver_path = driver_path
        super(Booking, self).__init__()


def land_first_page(self):
    self.get(const.BASE_URL

好像。chromedriver.exe 文件必须与您的脚本文件所在的目录相同

于 2021-10-31T19:20:26.707 回答
0

将您的chromedriver.exe文件复制到您当前的文件夹中path,以显示您可以使用的当前路径:

import sys
print(sys.path)

确保使用与浏览器相同的 chromedriver 版本

https://chromedriver.chromium.org/downloads

于 2021-10-31T20:06:27.010 回答