defnngj / pyautoTest

104 stars 99 forks source link

版本没问题,但是一直NameError: name 'driver' is not defined #4

Open gaogaowws opened 4 years ago

gaogaowws commented 4 years ago

2020-01-15 11:35:56,042 - INFO - 回归模式,开始执行✈✈! ============================= test session starts ============================= platform win32 -- Python 3.7.1, pytest-4.3.0, py-1.8.1, pluggy-0.13.1 -- C:\Users\bima\AppData\Local\Programs\Python\Python37\python.exe cachedir: .pytest_cache metadata: {'Python': '3.7.1', 'Platform': 'Windows-8.1-6.3.9600-SP0', 'Packages': {'pytest': '4.3.0', 'py': '1.8.1', 'pluggy': '0.13.1'}, 'Plugins': {'html': '2.0.0', 'metadata': '1.8.0', 'rerunfailures': '7.0'}, 'JAVA_HOME': 'F:\install\jdk1.8.0_111'} rootdir: F:\Workspaces\pyautoTest, inifile: plugins: html-2.0.0, metadata-1.8.0, rerunfailures-7.0 collecting ... collected 4 items

test_dir/test_baidu.py::TestSearch::test_baidu_search_case INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\main.py", line 210, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\main.py", line 250, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in call INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\main.py", line 271, in pytest_runtestloop INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in call INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pytest_rerunfailures.py", line 176, in pytest_runtest_protocol INTERNALERROR> reports = runtestprotocol(item, nextitem=nextitem, log=False) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\runner.py", line 87, in runtestprotocol INTERNALERROR> rep = call_and_report(item, "setup", log) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages_pytest\runner.py", line 175, in call_and_report INTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\hooks.py", line 286, in call INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 93, in _hookexec INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\manager.py", line 87, in INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, INTERNALERROR> File "C:\Users\bima\AppData\Local\Programs\Python\Python37\lib\site-packages\pluggy\callers.py", line 203, in _multicall INTERNALERROR> gen.send(outcome) INTERNALERROR> File "F:\Workspaces\pyautoTest\conftest.py", line 74, in pytest_runtest_makereport INTERNALERROR> capture_screenshot(case_name) INTERNALERROR> File "F:\Workspaces\pyautoTest\conftest.py", line 121, in capture_screenshot INTERNALERROR> driver.save_screenshot(image_dir) INTERNALERROR> NameError: name 'driver' is not defined

defnngj commented 4 years ago

主要是 driver 没有做全局定义,我加了全局定义,你再试试。