Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium | CSV file not downloading #1

Open
Sajjanparjapat opened this issue Aug 30, 2018 · 0 comments
Open

Selenium | CSV file not downloading #1

Sajjanparjapat opened this issue Aug 30, 2018 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@Sajjanparjapat
Copy link
Owner

Sajjanparjapat commented Aug 30, 2018

public class SystemSetup {

	public WebDriver driver;
	public FirefoxProfile profile;
	public static void main(String[] args) throws InterruptedException 
	{
		SystemSetup ss = new SystemSetup();
		ss.LoadFirefox();
	
		//Calling TestDownload.., 
		ss.testdownload();
	}
	
	public void LoadFirefox() {
		
		//Setting up browser compatibility
		File pathToBinary = new File("C:\\Users\\sajjankumar.parjapat\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
		FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
		profile = new FirefoxProfile();
		
		//download Preferences
		profile.setPreference("browser.download.folderList",2);
		profile.setPreference("browser.download.manager.showWhenStarting",false);
		profile.setPreference("browser.download.dir","D:\\Selenuim");
		profile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");
		driver = new FirefoxDriver(ffBinary,profile);
		driver.manage().window().maximize();
	}
	public void testdownload() throws InterruptedException {
		// TODO Auto-generated method stub
		
		driver.get("https://www.sample-videos.com/download-sample-csv.php");
		Thread.sleep(2000);
		WebElement csvfile = driver.findElement(By.xpath("html/body/div[4]/div[1]/div[2]/div[2]/table/tbody/tr[1]/td[4]/a"));
		csvfile.click();		
		Thread.sleep(5000);	
		driver.close();
	}
}
@Sajjanparjapat Sajjanparjapat added bug Something isn't working help wanted Extra attention is needed question Further information is requested labels Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant