'Python selenium stopped after download file

import warnings
warnings.filterwarnings('ignore')

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select 
import time

chromeOptions = webdriver.ChromeOptions() 
chromeOptions.add_argument("--profile-directory=AutoUser")
prefs = {"download.default_directory" : "C:\self_project\covid_project\covid19_project\dataset"} 
chromeOptions.add_experimental_option("prefs",prefs) 
chromedriver = 'C:/Users/LG/dev_python/Webdriver/chromedriver.exe' 
driver_chrome = webdriver.Chrome(executable_path=chromedriver, options=chromeOptions) 


driver_chrome.get("https://jumin.mois.go.kr/ageStatMonth.do") 
time.sleep(1)



download_btn = driver_chrome.find_element_by_id('csvDown')
download_btn.click() 
time.sleep(2)
download_btn.send_keys(Keys.RETURN)  # after this doesn't work....
time.sleep(5)

district_city = driver_chrome.find_element_by_name("sltOrgLvl1")
district_city_dropdown = Select(district_city) 
district_city_dropdown.select_by_index('1') 
time.sleep(1)

driver_chrome.close()

This image the captured image that stopped...

enter image description here

I want to continue code at the bottom(district_city part) or close the website. The website is stopped after download file, I think the download bar is the problem... How to I progress next step after download the file?



Solution 1:[1]

Try to replace your

download_btn.send_keys(Keys.RETURN)  # after this doesn't work....

with

driver_chrome.switch_to.alert.accept()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pL3b