I am using Python and Selenium to open different pages on PredictIt. So far I have this:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-notifications")
browser = webdriver.Chrome(options = chrome_options)
browser.get('https://www.predictit.org/account/')
#Input username into PredictIt
username = browser.find_element_by_id("username")
username.clear()
username.send_keys([MY USERNAME])
#Input password into PredictIt
password = browser.find_element_by_id("password")
password.clear()
password.send_keys([MY PASSWORD])
#Click login button
browser.find_element_by_xpath('//*[@id="app"]/div[3]/div/div/div/div[2]/div/form/div/div[6]/button[@type="submit"]').click()
browser.get_cookies() #get_cookies() allows it to stay logged in
browser.find_element_by_xpath('//*[@id="nav-markets"]').click()
The last line of code routes it to the "Markets" page. The issue I have is that this sometimes works and sometimes doesn't. I would say about 60% of the time, it clicks through and brings me to the page. The other 40% of the time, it stays on the current page after login and produces the error:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a href="/markets" class="main-nav__link" id="nav-markets">...</a> is not clickable at point (270, 24). Other element would receive the click: <div class="modal__wrapper">...</div>
(Session info: chrome=86.0.4240.198)
Would anyone have a solution to why this might be?