In our application, we upload PDF's into an interface. In this interface, the PDF is just a property of an object in a row that is displayed for the end user. The end user can see if a PDF has been uploaded for this row or not. Each PDF is unique to that row and must contain related data to the row's identity.

So my question is, is there a way to open the PDF in another tab, or download the PDF (by clicking on it) and then using the Selenium Web Driver to confirm/verify contents or if that it even exists?

We are using C#.

2 Answers 2


You can download the said PDF using Selenium webdriver, however I don't think you can verify the contents of the PDF, because that is not possible as far as I know using Selenium webdriver alone.

You can use Apache PDFBox to verify PDF contents- however it is a JAVA library. I am not sure whether you can combine PDFBox, along with Selenium and automate the whole process.

  • Downloading a PDF using Selenium webdriver

Use this code for C#

 FirefoxProfile profile = new FirefoxProfile();
 profile.SetPreference("browser.download.dir", @"c:\path\to\downloads\folder");   
 FirefoxDriver driver = new FirefoxDriver(profile);


Update the MIME/TYPE to be application/pdf since you are downloading a PDF file.


Selenium cannot perform any operation apart from web elements, pdf can be tested with the help of java Apache API for pdf

Go through this link https://pdfbox.apache.org/docs/1.8.10/javadocs/ to explore more about PDFbox API

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.