How do I close pop-up windows with Selenium in Python when I don't know when they will pop up?
I am trying to scrape historical weather data from this website: https://www.worldweatheronline.com/taoyuan-weather-history/tai-wan/tw.aspx
Using this code:
driver.find_element_by_css_selector("input[type='date']").send_keys(str(for_weather.mm[i])+str(for_weather.dd[i])+for_weather.year[i].astype(str))
wait=WebDriverWait(driver,10)
wait.until(EC.element_to_be_clickable((By.ID,'ctl00_MainContentHolder_butShowPastWeather'))).click()
temp=driver.find_element_by_xpath('//div[@class="days-collapse-temp"]').get_attribute('innerHTML')
One some of the pages, a popup appears. 
I've seen help that shows how to choose and close popups, but in my case, we don't know when they will show up. On some pages it appears, some don't. When they do show up, they prevent me from obtaining the data I want, and stops the loop. The following is the error message (it has the characteristics of the popup):
ElementClickInterceptedException: element click intercepted: Element <input type="submit" name="ctl00$MainContentHolder$butShowPastWeather" value="Get Weather" id="ctl00_MainContentHolder_butShowPastWeather" class="btn btn-success ml-2"> is not clickable at point (956, 559). Other element would receive the click: <div class="introjs-overlay" style="inset: 0px; position: fixed; cursor: pointer;"></div>
(Session info: chrome=97.0.4692.71)
Thanks much!
from Recent Questions - Stack Overflow https://ift.tt/3nnCXRb
https://ift.tt/34zR2o3
Comments
Post a Comment