first_heart 2019-07-24 09:07 采纳率: 0%
浏览 4118

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'

  • 写回答

3条回答

  • 风雨同ZZ 2019-07-24 09:16
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法