代码之家  ›  专栏  ›  技术社区  ›  Duma

Selenium-oserror:[winerrror 6]句柄无效

  •  0
  • Duma  · 技术社区  · 6 年前

    我试图保持自动Chrome窗口打开,但关闭时出现以下错误:

    Traceback (most recent call last):
      File "C:\Users\Duma\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 841, in __del__
        self._internal_poll(_deadstate=_maxsize)
      File "C:\Users\Duma\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1193, in _internal_poll
        if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
    OSError: [WinError 6] The handle is invalid
    

    使用 还有我的 蟒蛇脚本 如下所示:

    login_url='https://www.life4laptop.com/index.php?route=account/login'
    url='https://www.life4laptop.com/index.php?route=product/search&search=samsung'
    list=[]
    driver=webdriver.Chrome(crm_path, chrome_options=options)
    driver.get(login_url)
    elem = driver.find_element_by_id("input-email")
    elem.clear()
    elem.send_keys(x['life4laptop']['username'])
    elem = driver.find_element_by_id("input-password")
    elem.clear()
    elem.send_keys(x['life4laptop']['password'])
    elem = driver.find_element_by_xpath("//form/input[@type='submit']")
    elem.click()
    driver.get(url)
    
    driver2=webdriver.Chrome(crm_path, chrome_options=options)
    driver2.get(login_url)
    elem = driver2.find_element_by_id("input-email")
    elem.clear()
    elem.send_keys(x['life4laptop']['username'])
    elem = driver2.find_element_by_id("input-password")
    elem.clear()
    elem.send_keys(x['life4laptop']['password'])
    elem = driver2.find_element_by_xpath("//form/input[@type='submit']")
    elem.click()
    driver2.get(url)
    #driver.close()
    #driver.quit()
    

    任何线索 为什么 如何让它工作 ?

    2 回复  |  直到 6 年前
        1
  •  1
  •   adriaanbd    6 年前

    tearDown(self) driver.close() driver.quit()

    here

        2
  •  0
  •   Duma    6 年前