1

Language - JAVA IDE - Eclipse Tool - Selenium Web Driver

I have a test scenario where clicking on a link opens a new window with a pdf content being shown. The PDF shows up a form with Save and Cancel button. We don't get any element identifier using firebug for elements shown on the new window. How can I write a script to tell the driver to identify fields in the pdf and input something there followed by clicking on Save button.enter image description here

Srivastava
  • 3,500
  • 12
  • 46
  • 74

2 Answers2

0

Not sure if you can identify fields in a pdf using webdriver, since, in most cases, the pdf would be embedded in the browser and the fields in the pdf are not Html components. One thing you might want to check out is using AutoIt scripting and calling this script from your host program, in your case, java program. I have not tried using AutoIt for pdf but used it for other purposes and found that it is not difficult to learn and use.

You can call AutoIt executable from java program as follows: Runtime.getRuntime().exec("checkPDF.exe");

Since it is an executable, you might have portability issues if you plan on running your webdriver script on other platforms.

Sridevi Yedidha
  • 1,183
  • 1
  • 12
  • 13
0

Not going to work with Selenium. PDFs are usually displayed using native desktop applications/browser plugins and that is nothing Selenium can handle in general. BTW: what do you intend to test in a PDF formular? Seems pointless to me (at first sight).

What you CAN do is: take a desktop screenshot using AWT. And you should be able to use native desktop methods to simulate mouse clicks and key presses. But that is, well, not so nice [tm] because you may need to record the click coordinates and re-record them every time the PDF changes.

Maybe related: Interacting with a PDF popup in Selenium

Community
  • 1
  • 1
user1050755
  • 11,218
  • 4
  • 45
  • 56
  • Actually its not pointless as you see it, its just another scenario where post editing the pdf make changes to your account, and I need to verify it using selenium – Srivastava Mar 07 '13 at 15:26
  • Do you create the PDF programmatically? How do you get the form field values on the server side? I'm a bit clueless as to why one would want to use PDF as a web formular, especially when rendering it requires additional program installations on the client side. – user1050755 Mar 07 '13 at 15:29
  • Is it possible to check at least whether the new window is opened while clicking on the test link? I have tried with switch window option, but no luck... any clue? I'm looking to validate or retrieve the PDF content, just wanna ensure that a new window is opened on a button click. Hope that it's probably possible!!!! – zeal Jan 14 '16 at 18:16