How to accept popup message from Edge in IE mode Python - Selenium

66 views Asked by At

When I try to download a file from Edge in IE mode, I get a confirmation message for this download and I don't know how to overcome it, it doesn't allow me to accept commands like ALT + G, it doesn't matter if the file is, since what would matter is overcome this step of accepting (Save) or, failing that, some configuration that allows downloading without this message.

enter image description here

from selenium import webdriver
driver = webdriver.Ie(service=Service(executable_path="C:\IEDriverServer_Win32_4.14.0\IEDriverServer.exe"))
driver.get("https://www.winrar.es/descargas")
driver.find_element(By.XPATH, "//*[contains(text(),"Descargue WinRAR ahora")]").click()

I already tried sending

actions = ActionChains(driver)
actions.key_down(Keys.ALT).send_keys('g').key_up(Keys.ALT).perform()

but it doesn't work, just like sending it directly through js and neither

1

There are 1 answers

0
Kendrick Li On

I'm afraid you can't interact with the download popup using only Selenium commands. Selenium can't handle this popup. You need to take a look at tools like AutoIT to handle this popup.

If you want to simply skip this popup, you can try Wget:

import os

from selenium import webdriver
from selenium.webdriver.common.by import By


ie_options = webdriver.IeOptions()
ie_options.attach_to_edge_chrome = True
ie_options.ignore_protected_mode_settings = True
ie_options.edge_executable_path = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"

driver = webdriver.Ie(options=ie_options)

# We directly go to second URL to avoid auto-download, and avoid the popup.
driver.get("https://www.winrar.es/descargas/101/descargar-winrar-para-windows-x64-en-ingles")
# Get download URL
download = driver.find_element(By.XPATH, "//*[@id='subcontent']/table/tbody/tr[1]/td/a")
url_download = download.get_attribute("href")
# Download the file with Wget
os.system('cmd /c C:\\Windows\\System32\\wget.exe -P c:\\temp --no-check-certificate ' + url_download)