python NoSuchElementException Exception Handling

python crawler with Selenium simulate a click Times abnormal NoSuchElementException: Unable to locate ......

Error reason: https://www.cnblogs.com/cttcarrotsgarden/p/11210883.html

Usually it occurs when abnormal can not find the target element

Selenium introduction of packet NoSuchElementException

from selenium.common.exceptions import NoSuchElementException

try:
  xpath = ".//table//tr[1]//td[1]"
  browser.find_element_by_xpath(xpath).click()
NoSuchElementException the except: 
  Print ( "element not found!")

 

Guess you like

Origin www.cnblogs.com/cttcarrotsgarden/p/11210919.html