I have this code below to get comments from a page. Sometimes there are no comments, hence the except code triggers. It tries the try code block for like 5-10 seconds before executing the except code. Is there any faster way to check if the elements is found or not? Preferably: If the elements is not found then execute the except code directly.
try:
comments = WebDriverWait(driver, 20).until(
EC.presence_of_all_elements_located((By.XPATH, relativeXpathToReportComments)))
# some code to be executed if the elements is found
except:
print("could not find/get comments on comment page")