Hi Ashish,
I tried your solution and it didn't worked. Please give me the solution for my code
Use the below code to save the file after you click on export button.
Robot r = new Robot();
r.keyPress(KeyEvent.VK_DOWN);
r.keyRelease(KeyEvent.VK_DOWN);
r.keyPress(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_TAB);
r.keyPress(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_TAB);
r.keyPress(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_TAB);
Thread.sleep(2000);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
Let me know if you face any issue.
Thanks,
Elora
http://eloraparija.com
Hi Ashish,
I just don't want to just click on "OK" but I want to save it to the desired loacation
How can I do that ?
your code is fine cannot find any mistakes but its not working I don't know why.
give me some time.
I still can't find it. but there are few more things I could try. until then use robot class.
problems are with properties there is no property called
"browser.download.dir"
alternatively you can set configuration inside "about:config" and then call the same profile from selenium.
Hi Ashish/Team,
Even though 'browser.download.dir' firefox config is created manually and value is being updated by code,It is not working.
Also basic download code which was used in Module 16 to demonstrate download file in selenium with different MIME type is not working.
I am facing the same issue there as well and download window was not suppressed.
Could you please do the needful at the earliest ?
P.S. : I haven't strated the new thread as problem is same.
My FF version : 34.0
Selenium Webdriver : 2.45
Code :
public class Downloading_File {
/**
* @param args
*/
public static void main(String[] args) {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir","D:\\test");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword,application/x-rar-compressed,application/octet-stream,application/csv,text/csv");
WebDriver driver = new FirefoxDriver(profile);
driver.get("http://qtpselenium.com/test/testdownload.php");
driver.findElement(By.xpath("html/body/a[1]")).click();
driver.findElement(By.xpath("html/body/a[2]")).click();
driver.findElement(By.xpath("html/body/a[3]")).click();
}
}
create "Profile1" firefox profile and open "about:config"
search for value "browser.helperApps.neverAsk.saveToDisk" and manipulate it.
and by selenium call that "Profile1".
try this.
I did the same
1.) Manually created the profile - profile1
2.) Manually updated the 'browser.helperApps.neverAsk.saveToDisk' configuration for different MIME type.
3.) Accessed the same profile in code .
But No Luck. Please suggest.
Hi
Thanks for the acknowledgement
Please try to give solution which will work for all the applications
hey we are remaking the modules and it will be among newly uploaded modules.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", "F:\\temp");
//profile.setPreference("browser.helperApps.neverAsk.openFile",
//"text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ");
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
profile.setPreference("browser.download.manager.focusWhenStarting", false);
profile.setPreference("browser.download.manager.useWindow", false);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.closeWhenDone", true);
WebDriver driver = new FirefoxDriver(profile);