I am using Selenium Webdriver with C# for creating Automation test cases and have encountered an issue i.e. not able to automate the file download windows pop-up. On doing search over web, I found that this is a normal issue and there is a way to handle this with Selenium (not only 1 way but couple of ways), I have tried the following solutions but nothing is working.
Setting preferences of Firefox to automatically save files. I tried this but the Firefox instance which is launched by me (manually) is different from the instance launched by Selenium, so any setting done by me is not getting reflected to the Automated script. In addition to it, I don't want to go with this solution (although I tried).
Using solution combined from this link and SO Question1, SO Question2, in addition to it I explored from questions over SO and SQA related to this and; I have implemented something like this
FirefoxProfile prof = new FirefoxProfile(); FirefoxDriver driver = new FirefoxDriver(prof); driver.Navigate().GoToUrl("http://test.com/"); driver.Manage().Window.Maximize(); String title = driver.Title; driver.FindElement(By.Id("name-1")).Click(); driver.FindElement(By.Id("address-1")).Click(); prof.SetPreference("browser.download.dir", "C:\\Dhiman\\"); prof.SetPreference("browser.download.folderList", 2); //prof.SetPreference("browser.download.manager.showWhenStarting", false); prof.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip"); driver.FindElement(By.XPath("html/body/div/div/div/div/div/form/fieldset/div/a")).Click();
But this too is not working, as using this code "A new instance of Firefox is launched every time it is executed and that instance doesn't contain any download preference for 'Compressed Zipped Folder', even if I save it in the current instance, it is not shown when this script is executed again."
This solution I think can work for me, but here the Firefox is causing issues.
- Lastly, I found that I can use AutoIT for this, but that is a separate tool and I will need an approval from the Client and their IT department for downloading, installing and running that tool (a long long process with lots of approvals) as I am working on client provided machine.
How this issue of downloading files can be resolved without using AutoIT? IS there a way to resolve this Firefox issue permanently?
If any more information is required, just out the same query/info. needed in comments section of this question and will add that information too.
Please read the full question, as the problem is not only related to downloading, and I have already gone through SO links, some of them are referenced in questions itself.