Question
How to verify pdf content using selenium 2.0

Answers

I will explain the procedure to verify PDF file content using java webdriver. As some time we need to verify content of web application pdf file, opened in browser. Use below code in your test scripts to get pdf file content.

//get current urlpdf file url
URL url = new URL(driver.getCurrentUrl());

//create buffer reader object
BufferedInputStream fileToParse = new BufferedInputStream(url.openStream());
PDFParser pdfParser = new PDFParser(fileToParse);
pdfParser.parse();

//save pdf text into strong variable
String pdftxt = new PDFTextStripper().getText(pdfParser.getPDDocument());

//close PDFParser object
pdfParser.getPDDocument().close();

After applying above code, you can store all pdf file content into “pdftxt” string variable. Now you can verify string by giving in put. As if you want to verify “Selenium Or Webdiver” text. Use below code.

Assert.assertTrue(pdftxt.contains(“Selenium Or Webdiver”))   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q What are group policies
  • Q Differentiate between % ROWTYPE and TYPE RECORD?
  • Q What's RequisitePro ?
  • Q In an atom the order of filing up of the orbitals is governed by-
  • Q Your organization has many databases on many servers, and a large number of users. The network environment is always changing. What would be the best naming method to use? (Choose the best answer.) A. Easy Connect, because it means that you don’t have to maintain tnsnames .ora files. B. Directory naming, because it centralizes the naming information. C. Local naming, because each user can maintain his own configuration files locally. D. External naming, because you can rely on a third-party product to maintain the configuration information.
  • Q What does crm stand for?
  • Q What’s the best method for video output using media encoder?
  • Q How are web parts developed?
  • Q Almeria, Merlot, and Waltham Cross are which fruit?
  • Q How can you increase the number of columns in a worksheet?
  • Q What is the angle between them?