Answer the question
In order to leave comments, you need to log in
How to check if an element is on a page in selenium python using if?
How to do it with no try and except
Answer the question
In order to leave comments, you need to log in
Now it's fashionable something like this:
driver.implicitly_wait(15)
if bool(driver.find_elements(by="class name", value='blabla')):
print('Yesss')
else:
print('Nooo')
def check_exists_by_xpath(xpath):
try:
webdriver.find_element_by_xpath(xpath)
except NoSuchElementException:
return False
return True
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question