Search code examples
google-chromeseleniumautomationpdfboxbufferedinputstream

Selenium- Read a pdf that opens in New tab without url


In our application , we have a scenario where we click on a link and after clicking a new tab opens with a dynamically generated PDF.

The generated PDF opens in new tab with "about:blank" as the URL.

To verify the content of the PDF i am not able to use below code since there is no specific URL

URL TestURL = new URL("url");
BufferedInputStream TestFile = new BufferedInputStream(TestURL.openStream());
PDFParser TestPDF = new PDFParser(TestFile);

TestPDF.parse();
String TestText = new PDFTextStripper().getText(TestPDF.getPDDocument());

I don't have option to download the generated PDF as well.

Is there any way we can solve this ?? Thank you in advance.


Solution

  • Try using Actions class to select all the content using "CTRL+A" then copy ("CTRL+C") and then paste it somewhere you can extract the text and verify.