selenium中,運行測試用例,報NosuchElementException錯誤,用try --except 捕獲異常


try:

      ele=driver.find_element_by_name('kw')

except  NosuchElementException as msg:

      print '查找元素異常原因:%s'%msg

else:
      ele.click()

 

selenium常見異常

1.NoSuchElementException:沒有找到元素

2.NoSuchFrameException:沒有找到iframe

3.NoSuchWindowException:沒找到窗口句柄handle

4.NoSuchAttributeException:屬性錯誤

5.NoAlertPresentException:沒找到alert彈出框

6.lementNotVisibleException:元素不可見

7.ElementNotSelectableException:元素沒有被選中

8.TimeoutException:查找元素超時

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM