This is a migrated thread and some comments may be shown as answers.

Check pdf

9 Answers 233 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 10 Sep 2012, 02:10 PM
Hello,
I need check stamp in pdf file using telerik(special text in pdf file) Is possible in Telerik Test Studio?
Thank you for answer.

9 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 10 Sep 2012, 02:22 PM
Hi Jan,

I am sorry but Test Studio is not able to automate PDF files. The problem is that a PDF file does not have any HTML that we can parse. They are basically like a black box and we do not have any way of seeing the contents of them.

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Jan
Top achievements
Rank 1
answered on 10 Sep 2012, 02:45 PM
Are you plan to add this option to Telerik in the future? It will be very helpful, because we have website which generates pdf files and we would like to check if they are correctly generated.
0
Plamen
Telerik team
answered on 11 Sep 2012, 10:55 AM
Hi Jan,

I am sorry, but the answer is no. We have no plans to ever automate PDF files.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Milan
Top achievements
Rank 1
answered on 28 Mar 2013, 07:29 PM
How do you suggest we verify PDF pop-ups?
0
Plamen
Telerik team
answered on 29 Mar 2013, 01:14 PM
Hi Milan,

Test Studio cannot connect to or record against a pop-up window that directly loads a PDF file. This is because it does not have a DOM like a traditional web page. If appropriate, you could visually verify the result and then program a keyboard input (like ALT+F4) to close out of the PDF pop-up and continue the test. The most reliable method to verify that the PDF document exists and can be successfully downloaded is to use a coded step following this code sample. In your case, you will skip parsing the returned data. You only need to verify that "OK" is returned to the HTTP GET request.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Himanshu
Top achievements
Rank 2
answered on 02 Apr 2013, 09:32 AM
You can use the Desktop Capture step where PDF is opening before closing the popup. Once the test is done, you can verify the screen caps manually by looking at them.
0
Andy
Top achievements
Rank 1
answered on 30 Mar 2017, 07:09 PM
This post is for Boyan.  He found a great solution to this issue, but unfortunately our paths separated before he could post a reply.  So I am here to post what Boyan found.  Thank you Boyan, wherever you are:
Hi guys,

After further researching I have found a very simple solution on how to read a pdf file in code.

1. Download iTextShart from here. It is a free .NET PDF library.
2. Add itextsharp.dll to Test Studio from \itextsharp-all-5.5.8\itextsharp-dll-core folder. Note that before adding you should unblock the dll (right click  -> properties -> unblock).
3. Use that code for reading a pdf file:

Dim fileName As String = "folder\\pdfFileName.pdf"
            Dim text As New StringBuilder()

            If File.Exists(fileName) Then
Dim pdfReader As New PdfReader(fileName)

For page As Integer = 1 To pdfReader.NumberOfPages
Dim strategy As ITextExtractionStrategy = New SimpleTextExtractionStrategy()
Dim currentText As String = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy)

currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.[Default], Encoding.UTF8, Encoding.[Default].GetBytes(currentText)))
                        text.Append(currentText)
                         Log.WriteLine(text.ToString())
Next
                        pdfReader.Close()
End If

After executing the coded step the entire text of the pdf file will be stored into “text” string variable and will be logged into the execution log of the test.
0
Andy
Top achievements
Rank 1
answered on 30 Mar 2017, 07:56 PM
sorry the 2 links dropped out: 
Download iTextShart from here: https://sourceforge.net/projects/itextsharp/files/?source=navbar
and
Add itextsharp.dll: http://docs.telerik.com/teststudio/features/coded-steps/add-assembly-reference

Andy Wieland
0
Elena
Telerik team
answered on 04 Apr 2017, 01:27 PM
Hi,

Thanks Andy for sharing the solution in public. I hope it will be useful to anyone looking for this functionality! 

Regards,
Elena Tsvetkova
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Jan
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Jan
Top achievements
Rank 1
Milan
Top achievements
Rank 1
Himanshu
Top achievements
Rank 2
Andy
Top achievements
Rank 1
Elena
Telerik team
Share this question
or