Discussion:
Downloading a File
Samuel Facchinello
2014-04-01 14:56:25 UTC
Permalink
Hi, I'm Samuel of Brazil.
following this tutorial:
http://elementalselenium.com/tips/2-download-a-file

Implemented in Java with selenium version 2.41. Worked perfectly with the
image, but with txt (and xml from another site) does not work, always opens
the download window.

Any tips?

Thank you.



CODE:

FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.
setAcceptUntrustedCertificates(true);
firefoxProfile.setPreference("browser.download.folderList",2);//browser
dir
firefoxProfile.setPreference("browser.download.dir",tempDir);
firefoxProfile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/xml,text/plain,text/xml,image/jpeg");

driver = new FirefoxDriver(firefoxProfile);

driver.get("http://the-internet.herokuapp.com/download");

new WebDriverWait(driver, 10).until(ExpectedConditions.
presenceOfElementLocated(By.className("example")));

driver.get("http://the-internet.herokuapp.com/download/dummy.txt
");
driver.get("
Loading Image...");
driver.quit();
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to selenium-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/be55e2db-065c-469f-a7dc-6d27c714c86c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Collin
2014-04-03 08:06:39 UTC
Permalink
I'll link you to my various things about file downloads in Selenium:

https://skillsmatter.com/skillscasts/5068-what-did-you-just-download
http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt
https://github.com/Ardesco/What-Did-You-Download
http://www.slideshare.net/Ardesco/what-did-you-just-download
Post by Samuel Facchinello
Hi, I'm Samuel of Brazil.
http://elementalselenium.com/tips/2-download-a-file
Implemented in Java with selenium version 2.41. Worked perfectly with the
image, but with txt (and xml from another site) does not work, always opens
the download window.
Any tips?
Thank you.
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.
setAcceptUntrustedCertificates(true);
firefoxProfile.setPreference("browser.download.folderList",2
);//browser dir
firefoxProfile.setPreference("browser.download.dir",tempDir);
firefoxProfile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/xml,text/plain,text/xml,image/jpeg");
driver = new FirefoxDriver(firefoxProfile);
driver.get("http://the-internet.herokuapp.com/download");
new WebDriverWait(driver, 10).until(ExpectedConditions.
presenceOfElementLocated(By.className("example")));
driver.get("
http://the-internet.herokuapp.com/download/dummy.txt");
driver.get("
http://the-internet.herokuapp.com/download/avatar.jpg");
driver.quit();
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to selenium-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4e169140-7f4a-4d51-be60-a126f68d22a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ashok kumar
2014-04-02 13:32:21 UTC
Permalink
Look for ''Handling windows dialogs'' section in below link.

http://automationtestingutilities.blogspot.in/

-Ashok
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to selenium-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/69884c82-4300-47fb-a632-df1ff7d21794%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Samuel Facchinello
2014-04-04 11:44:22 UTC
Permalink
Hey guys, problem solved, it was sufficient to add the correct mimetype
'application/octet-stream' in "browser.helperApps.neverAsk.saveToDisk" and
everything worked perfectly.

Thanks for the tips.


Em terça-feira, 1 de abril de 2014 11h56min25s UTC-3, Samuel Facchinello
Post by Samuel Facchinello
Hi, I'm Samuel of Brazil.
http://elementalselenium.com/tips/2-download-a-file
Implemented in Java with selenium version 2.41. Worked perfectly with the
image, but with txt (and xml from another site) does not work, always opens
the download window.
Any tips?
Thank you.
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.
setAcceptUntrustedCertificates(true);
firefoxProfile.setPreference("browser.download.folderList",2
);//browser dir
firefoxProfile.setPreference("browser.download.dir",tempDir);
firefoxProfile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/xml,text/plain,text/xml,image/jpeg");
driver = new FirefoxDriver(firefoxProfile);
driver.get("http://the-internet.herokuapp.com/download");
new WebDriverWait(driver, 10).until(ExpectedConditions.
presenceOfElementLocated(By.className("example")));
driver.get("
http://the-internet.herokuapp.com/download/dummy.txt");
driver.get("
http://the-internet.herokuapp.com/download/avatar.jpg");
driver.quit();
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to selenium-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b02d1ae0-ca93-428b-946c-4601dfd8062d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...