I have a task to click on "Generate PDF", then automate the PDF to see if the data is present as expected. However, I am not able to select last generated PDF.... it takes only the first pdf file. Every time when i click on "Generate PDF" file gets generated --------> example: ("file:///home/tifoso/Downloads/Search by Criteria.pdf"),("file:///home/tifoso/Downloads/Search by Criteria(1).pdf".....etc)
My code so far:
public void readPDF_ProvidersList() throws IOException {
System.out.println("_______Testing PDF file_______");
URL url = new URL("file:///home/tifoso/Downloads/Provider List.pdf");
InputStream is = url.openStream();
BufferedInputStream fileParse = new BufferedInputStream(is);
PDDocument document = null;
document = PDDocument.load(fileParse);
String pdfContent = new PDFTextStripper().getText(document);
System.out.print(pdfContent);
Assert.assertTrue(pdfContent.contains("License/Provider"));
Assert.assertTrue(pdfContent.contains("Address"));
Assert.assertTrue(pdfContent.contains("Phone"));
Assert.assertTrue(pdfContent.contains("Email"));
Assert.assertTrue(pdfContent.contains("Gender"));
Assert.assertTrue(pdfContent.contains("Ethnicity"));
Assert.assertTrue(pdfContent.contains("Highly"));
Assert.assertTrue(pdfContent.contains("Recommended"));
Assert.assertTrue(pdfContent.contains("Metro"));
}
How do i specify in my code that i want system to use the latest generated PDF? It is dynamic and will change every time i will click "Generate PDF"