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

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

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!