Module 17 Part 3 File is NOT downloading in specific folder but is download in download folder | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
10% May Month Discount Avail now

Selenium Training Forum

Module 17 Part 3 File is NOT downloading in specific folder but is download in download folder

K
Kam Post on 27/02/2019

file is NOT downloading in : C:\\seleniumdownloads BUT is downloading in default folder

 

package Download;

 

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.firefox.FirefoxOptions;

import org.openqa.selenium.firefox.FirefoxProfile;

import org.testng.annotations.Test;

 

public class FFDLoad {

///===================================Module 17 PART 3================================================

 

//public static String downloadPath = "C:\\seleniumdownloads";

 

@Test

public void FFDownloadTest1() throws InterruptedException

{

 

FirefoxOptions ops = new FirefoxOptions();

FirefoxProfile profile = new FirefoxProfile ();

 

profile.setPreference("browser.download.folderlist", 2);

//profile.setPreference("browser.download.manager.showWhenStarting",false);

profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");

profile.setPreference("browser.download.dir","C:\\seleniumdownloads");

//profile.setPreference("browser.download.dir", downloadPath);

ops.setProfile(profile);

 

WebDriver driver = new FirefoxDriver(ops);

driver.get("http://qtpselenium.com/test/testdownload.php");

//Thread.sleep(5000);

driver.findElement(By.linkText("Word Doc")).click();

}

}

 

D

Instructor

Demo Reply on 28/02/2019

Yes.. thats how code is made in that file FFDLoad 

You will have to modify it if you want it directly and not in download folder

K
Kam Reply on 28/02/2019

changes are in code:

profile.setPreference("browser.download.dir","C:\\seleniumdownloads");

K
Kam Reply on 28/02/2019

changes are in code:

profile.setPreference("browser.download.dir","C:\\seleniumdownloads");

D

Instructor

Demo Reply on 12/03/2019

I noticed multiple issues with the code. You're not referring the video properly.

Examine the code snippet below

FirefoxOptions ops = new FirefoxOptions();
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("SeleniumTest");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/vnd.openxmlformats-officedocument.wordprocessingml.document");
profile.setPreference("browser.download.dir", "A:\\Selenium Downloads");
profile.setPreference("browser.download.folderList", 2);

Analyse the code above and make changes accordingly.

K
Kam Reply on 22/03/2019

Thanks for your help.

What I understand that commands should be in specific orded, I have in wrong order. Is it correct?

I put 1 - folder list    2-save to disk  3- Folder dir 

while it should be : 1-save to disk  2- Folder dir  and 3 - folder list 

D

Instructor

Demo Reply on 23/03/2019

folder dir and folder list should be in correct sequence.