capture a downloaded pdf file name with selenium webdriver

Need to capture the the file name of a PDFs which we get by clicking a download link in a URL. I've tried with this code.but, I cannot get the title or url from the second window kindly help me out with this or suggest me any other methods to handle this...

**code I tried**

@Test

public void pdfname() throws Exception {  
driver.get(baseUrl + "/english/investments/iv_funds.htm");  
Set<String> winids = driver.getWindowHandles();  
Iterator<String> iterate = winids.iterator();  
Thread.sleep(3000);  
driver.findElement(By.linkText("FUND MATERIALS")).click();  
Thread.sleep(3000);  
driver.findElement(By.className("sbToggle")).click();  
Thread.sleep(3000);  
driver.findElement(By.linkText("Fund Details and Performance Update")).click();  
driver.findElement(By.id("fundPerformance")).click();  
driver.findElement(By.id("fundPerformance")).clear();  
driver.findElement(By.id("fundPerformance")).sendKeys("AEGAU");  
Thread.sleep(3000);  
driver.findElement(By.xpath("//*[@id='perform']")).click();  
Thread.sleep(18000);  
winids = driver.getWindowHandles();  
iterate = winids.iterator();  
String firstwindow=iterate.next();  
String secondwindow = iterate.next();  
System.out.println(firstwindow);  
System.out.println(secondwindow);  
driver.switchTo().window(secondwindow); //switch to pdf window  
Thread.sleep(3000);  
System.out.println("url is"+driver.getCurrentUrl());  
driver.close();  
}  

Answers


I think you are trying to get the name from a OS system window. Selenium does not interact with the OS. For windows you can use autoit (http://www.autoitscript.com/site/autoit/) to interact with the OS.


Need Your Help

Ionic Add Platform EACCES Error

macos cordova ionic

Whenever I use ionic platform add [platformname] It gives me this error