I have a notification that appears in a couple of times a week on this website I scrape. And I can't get around it.
I can run the code.
el = driver.find_element_by_xpath("//input[@id='btnRead']")
driver.execute_script("arguments[0].click();", el)
Which clears it, but if I leave it in my code it gives me a no such element exception. Event if I try to wrap it in try/catch like so.
from selenium.common.exceptions import NoSuchElementException
try:
el = driver.find_element_by_xpath("//input[@id='btnRead']")
driver.execute_script("arguments[0].click();", el)
except NoSuchElementException:
print(nonefound)
sleep(5)
driver.quit()
This also clears it, if it exists but if it doesn't, error. I assume I am doing something wrong but I have tried a few different versions of this and I always get the error which leaves the windows hanging and stops the execution of the rest of the script.
Any ideas would be great.