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

前端 未结 5 525
太阳男子
太阳男子 2020-12-05 19:41

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 P

5条回答
  •  情书的邮戳
    2020-12-05 19:54

    You cannot do this using WebDriver natively. However, PDFBox API can be used here to read content of PDF file. You will have to first of all shift a focus to browser window where PDF file is opened. You can then parse all the content of PDF file and search for the desired text string.

    Here is a code to use PDFBox API to search within PDF document.

提交回复
热议问题