AttributeError: '----' object has no attribute 'driver'。

这几天公司做web自动化脚本,,等做完我用着好好的,别人一用突然有的能跑有的报这个错误,

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see

AttributeError: 'BasicInformationCase' object has no attribute 'driver'

在网上找了很多类似的方法可是有的说setUp问题,关键我这个没有写setUp方法啊!
而且我的电脑就能都跑通,别人的电脑就有的能跑通,有的不能跑通,求助各位大神帮帮忙,看看什么原因

异常信息:
'Traceback (most recent call last):
File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "D:\software\python3.7.2\lib\subprocess.py", line 775, in init
restore_signals, start_new_session)
File "D:\software\python3.7.2\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 35, in BasicInformationCase
text = self.__Demo(excelData,Number_of_cases, i, flow)
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 70, in Demo
self.
Init_driver_Chrome()
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 144, in Init_driver_Chrome
self.driver = webdriver.Chrome(executable_path='C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe', chrome_options=options) # 启动浏览器
File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init

self.service.start()
File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

异常信息:
'Traceback (most recent call last):
File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "D:\software\python3.7.2\lib\subprocess.py", line 775, in init
restore_signals, start_new_session)
File "D:\software\python3.7.2\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 35, in BasicInformationCase
text = self.__Demo(excelData,Number_of_cases, i, flow)
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 70, in Demo
self.
Init_driver_Chrome()
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 144, in Init_driver_Chrome
self.driver = webdriver.Chrome(executable_path='C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe', chrome_options=options) # 启动浏览器
File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init

self.service.start()
File "D:\software\python3.7.2\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

异常信息:
'Traceback (most recent call last):
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 35, in BasicInformationCase
text = self.__Demo(excelData,Number_of_cases, i, flow)
File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 77, in __Demo
restext.append(bsm.BasicInformation_Son_Module(self.driver,excelData,Number_of_cases, i))
AttributeError: 'BasicInformationCase' object has no attribute 'driver'

2个回答

别人可能没有装chromedriver或者其他浏览器的driver

first_heart
first_heart 不是的,,,我搞错了,,,webdriver.Chrome(executable_path="")我配置了我的驱动地址,,,哈哈!!问题解决了谢谢了
大约一年之前 回复

一目了然 是配置路径问题 具体什么路径自己找找

qq_38154948
拉灯的小手 回复: 追溯一下报错信息一下就看到了
大约一年之前 回复
qq_38154948
拉灯的小手 回复first_heart: File "D:\工作文件\自动化脚本\abc\Template\BasicInformationCase.py", line 144, in Init_driver_Chrome self.driver = webdriver.Chrome(executable_path='C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe', chrome_options=options) # 启动浏览器
大约一年之前 回复
qq_38154948
拉灯的小手 回复first_heart: FileNotFoundError: [WinError 2] 系统找不到指定的文件。
大约一年之前 回复
first_heart
first_heart 你在哪段报错代码中看到是路径的问题
大约一年之前 回复
first_heart
first_heart ....
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问