try: WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "locator"))) not_found = False except: not_found = True assert not_found