Verifying Information From a PDF

Tips and Techniques

Moderators: ZeenyxSupport, blesuer

Post Reply
andreawaldorf
Posts: 2
Joined: Thu Oct 18, 2012 10:35 am

Verifying Information From a PDF

Post by andreawaldorf »

I needed a way to use AscentialTest to verify information in a PDF file. Since AscentialTest cannot hook into the PDF itself, I was able to do the following to achieve my goal.

Code: Select all

[ ] System.SetClipboard({})  // clear the Clipboard of any prior information
[ ] PDFWindow.Click()
[ ] PDFWindow.TypeKeys("<Ctrl-a>")  // highlights the entire set of text of the PDF
[ ] PDFWindow.TypeKeys("<Ctrl-c>")  // copies it to the clipboard
[ ] Sleep(2)
[ ] List<String> lsClipboard = System.GetClipboard()
Now if you say

Code: Select all

[]Print(lsClipboard)
you will see something like:

[1] Line 1
[2] DataName: Value
[3] blah blah
....
You can then use all of the String methods available to verify the various lines. For example, I had a line that looked like:

[8] Name: Harry Smith

I needed to verify the name was "Harry Smith" so I did the following:

Code: Select all

[]VerifyValue("Customer name is correct: ", "Harry Smith", lsClipboard[8].GetField(": ", 2))
Post Reply