问题描述:执行多个用例的时候,会抛出异常:
Traceback (most recent call last): File "F:DemopomGisStugis est_casemodelsmytest.py", line 9, in setUp self.driver = browser() File "F:DemopomGisStugis est_casemodelsdriver.py", line 4, in browser return webdriver.Chrome() File "F:软件python3.6.1libsite-packagesseleniumwebdriverchromewebdriver.py", line 61, in __init__ self.service.start() File "F:软件python3.6.1libsite-packagesseleniumwebdriverchromeservice.py", line 66, in start self.service_args, env=env, stdout=PIPE, stderr=PIPE) File "F:软件python3.6.1libsubprocess.py", line 594, in __init__ _cleanup() File "F:软件python3.6.1libsubprocess.py", line 205, in _cleanup res = inst._internal_poll(_deadstate=sys.maxsize) File "F:软件python3.6.1libsubprocess.py", line 1025, in _internal_poll if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0: OSError: [WinError 6] 句柄无效。
问题分析:
经查询得知,是因为后台有多个chromedriver.exe被启动,应该关闭它,自测得知最多只能打开三个测试用例的的浏览器
解决办法:
利用quit()方法关闭浏览器,不能使用close()方法关闭。