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:查找元素超時