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.[ ] 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[]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:
[]VerifyValue(“Customer name is correct: “, “Harry Smith”, lsClipboard[8].GetField(“: “, 2))
Contact Our Team