I run this code
#Gets to the Calendar for the week with the Login Details
calendar = driver.get('https://www.investing.com/economic-calendar/')
time.sleep(5)
driver.find_element_by_xpath('/html/body/div[9]/div[3]')
driver.find_element_by_xpath('//*[@id="onetrust-accept-btn-handler"]').click()
time.sleep(5)
driver.find_element_by_xpath('/html/body/div[10]/div')
driver.find_element_by_xpath('/html/body/div[10]/div/div[4]/button[1]').click()
Sometimes I successful sometimes I get error
ElementClickInterceptedException: element click intercepted: Element <a onclick="overlay.overlayLogin();" href="javascript:void(0);" class="login bold">...</a> is not clickable at point (821, 19). Other element would receive the click: <div class="allow-notifications-popup-wrapper shown">...</div>
(Session info: chrome=84.0.4147.135)
Because a naughty pop-up/alert doesn't always appear.
How can I write a IF (pop up is there) THEN click it
OR
IF pop-not there skip the following two lines?
Thanks