I have the following code:
However, the element I am looking for is optional. It will sometimes be present and sometimes not. I want to keep track whether it is present. If it is not present, the code should not be terminated because driver.find_element throws a the
NoSuchElementException error. I want to code to continue.
You can use try..except block to ignore if element not present
try: driver.find_element(By.XPATH, "/html/body/...").text except: pass