Page 1 of 1

Verifying Information From a PDF

Posted: Wed Apr 06, 2016 1:32 pm
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))