How to start automatic download of a file in Internet Explorer?
SourceForge uses an <iframe>
element with the src=""
attribute pointing to the file to download.
<iframe width="1" height="1" frameborder="0" src="[File location]"></iframe>
(Side effect: no redirect, no JavaScript, original URL remains unchanged.)
How to automatically download file in IE in locked screen
As far as I know, WebDriver has no capability to access the IE Download dialog boxes presented by browsers when you click on a download link or button. But, we can bypass these dialog boxes using a separate program called "wget".
we can use command-line program and this wget to download the file. Code as below (the following code is C# code, you could convert it to Python):
var options = new InternetExplorerOptions()
{
InitialBrowserUrl = URL, // "http://demo.guru99.com/test/yahoo.html";
IntroduceInstabilityByIgnoringProtectedModeSettings = true
};
//IE_DRIVER_PATH: @"D:\Downloads\webdriver\IEDriverServer_x64_3.14.0";
var driver = new InternetExplorerDriver(IE_DRIVER_PATH, options);
driver.Navigate();
Thread.Sleep(5000);
//get the download file link.
String sourceLocation = driver.FindElementById("messenger-download").GetAttribute("href");
Console.WriteLine(sourceLocation);
//using command-line program to execute the script and download file.
String wget_command = @"cmd /c D:\\temp\\wget.exe -P D:\\temp --no-check-certificate " + sourceLocation;
try
{
Process exec = Process.Start("CMD.exe", wget_command);
exec.WaitForExit();
Console.WriteLine("success");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
driver.Close(); // closes browser
driver.Quit(); // closes IEDriverServer process
More details, you could refer to this article.
Edit: Since you are using python, you could use the find_element_by_id method to find the element, then using the get_attribute method to get the value. More details, you could check these articles:
Get Element Attribute
Python + Selenium for Dummies like Me
WebDriver API
Get value of an input box using Selenium (Python)
How to enable automatic downloads in IE11
I found a way to do this, but you need to use User32.dll sendmessage() function, after you press button\link and you have your download dialog i use sendmessage to send key's i send:
1- (F6) it will select the download dialog.
2-(Tab) -it will select the first option Save.
3- (Enter) will press Save button that will save file to deafault derectory
4- For 100% i check in registry the defeaul folder of IE and easy find my file and copy it to directory that i need.
Why i use sendmessage and not sendKey?
Answer: sendmessage will still press on buttons even if windown is lock no need UI.
Related Topics
Html ≪Select≫ Selected Option Background-Color CSS Style
How to Parse HTML in Google Apps Script
Creating Svg Elements Dynamically With JavaScript Inside Html
Setting CSS Pseudo-Class Rules from JavaScript
How to Disable a CSS :Hover Effect Via JavaScript
How to Add Multiple Classes to a Reactjs Component
Er_Not_Supported_Auth_Mode - MySQL Server
Sort Array of Objects by String Property Value
Get Selected Value in Dropdown List Using JavaScript
Changing the Selected Option of an HTML Select Element
Want to Add "Addeventlistener" on Multiple Elements With Same Class
How to Show a Hidden Div When a Select Option Is Selected
Angular: Conditional Class With *Ngclass
Removing or Replacing a Stylesheet (A ≪Link≫) With JavaScript/Jquery