I am trying to download a .pdf to my local so that I can use Apache PDFBox to read the text from it and verify it as a part of my test suite. I have already found some code to download the pdf from Firefox by hitting a URL. This does not work for me since the pdf I am working with is a confidential document so it is not exposed by a URL, instead loaded within PDF Viewer as a popup window. Does anyone know how to hit the download button within the Firefox PDF Viewer after I have loaded the PDF Viewer in the browser?
I have tried looking it up by the element's id which = "download":
(new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("download")));
driver.findElement(By.id("download")).click();
Unfortunately this does not work as it says it cannot find the element. Anyone know a workaround?
UPDATE: The pop-up window I described was an iframe element. This caused the inability to find the "download" element. Fixed with @4M01's switchTo() answer.