Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 28, 2016 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/da40aa1c5e4b4050c9a0 to your computer and use it in GitHub Desktop.
Save angelovstanton/da40aa1c5e4b4050c9a0 to your computer and use it in GitHub Desktop.
[TestMethod]
public void VerifyFileDownloadFirefox()
{
string expectedFilePath = @"c:\temp\Testing_Framework_2015_3_1314_2_Free.exe";
try
{
String downloadFolderPath = @"c:\temp\";
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("browser.download.folderList", 2);
profile.SetPreference("browser.download.dir", downloadFolderPath);
profile.SetPreference("browser.download.manager.alertOnEXEOpen", false);
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword, application/binary, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream");
this.driver = new FirefoxDriver(profile);
driver.Navigate().GoToUrl("https://www.telerik.com/download-trial-file/v2/telerik-testing-framework");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until((x) =>
{
return File.Exists(expectedFilePath);
});
FileInfo fileInfo = new FileInfo(expectedFilePath);
long fileSize = fileInfo.Length;
Assert.AreEqual(4326192, fileSize);
}
finally
{
if (File.Exists(expectedFilePath))
{
File.Delete(expectedFilePath);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment