zoukankan      html  css  js  c++  java
  • 【Selenium + Python】之OSError: [WinError 6] 句柄无效。

    问题描述:执行多个用例的时候,会抛出异常:

    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()方法关闭。

  • 相关阅读:
    你写的单例真的安全吗?
    CountDownLatch&&CyclicBarrier
    初步认识AQS
    Atomic底层原理
    volatile关键字
    Linux常用服务类相关命令
    线程池
    由浅入深TheradLocal
    synchronized关键字
    .net 中dapper实现事务的三种方式总结
  • 原文地址:https://www.cnblogs.com/Owen-ET/p/9377054.html
Copyright © 2011-2022 走看看