Can Selenium verify text inside a PDF loaded by the browser?

Viewed 44311

My web application loads a pdf in the browser. I have figured out how to check that the pdf has loaded correctly using:

verifyAttribute xpath=//embed/@src {URL of PDF goes here}

It would be really nice to be able to check the contents of the pdf with Selenium - for example verify that some text is present. Is there any way to do this?

5 Answers

There is a way.

  1. Before you click the link you can obtain the href value element.FindElement(By.TagName("href")).Text
  2. Then after the PDF loads you can get the Url driver.GetUrl();
  3. Then you can just check to see if the url contains the href.

It's not the best, but it's better than nothing.

Related