I have a download button without href link in a webpage. I find it with findExtendedelement and click on it. After the click a zip file download on the hard drive (i dont know where, and it shouldn't be matter) I would like to catch this downloaded zip and put it in my project, for example build/reports/tests/temp folder.
Is it possible with selenium?
Update
The HTML looks: https://i.stack.imgur.com/YnhlH.jpg
I tried this code:
@Test
public void userCanDownloadFile() throws FileNotFoundException, IOException
{
// Folder to store downloads and screenshots to.
reportsFolder = "./src/test/profiles/chrome/downloads/";
open("http://chromedriver.storage.googleapis.com/index.html?path=2.16/");
// Download files
$("a[href='/2.16/chromedriver_win32.zip']").download();
$(By.xpath(".//a[@href='/2.16/chromedriver_mac32.zip']")).download();
// Count files in folder, assert 2
int downloadsCount = new File(reportsFolder+"2.16").listFiles().length;
assertEquals("Should be 2 files but founded " + downloadsCount,
downloadsCount, 2);
// Clean after test
FileUtils.deleteDirectory(new File(reportsFolder+"2.16"));
}
Result: java.lang.IllegalArgumentException: The element does not have href attribute:
The code is from: http://selenide-recipes.blogspot.com/2015/08/how-to-download-file-with-selenide.html
I'm looking for something like that, I can handle the downloaded file in my project. (in reportsFolder path) Unfortunately, this solution doesn't work, because the ExtendedElement (findExtendedElement("span", "class", "download_0") doesn't have an "a href" tag)
Thanks