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

verifications on pdf reports

15 Answers 128 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 13 Apr 2011, 06:16 PM
Is it possible to perform verifications on pdf reports?

15 Answers, 1 is accepted

Sort by
0
Daniel Levy
Telerik team
answered on 18 Apr 2011, 10:29 PM
Hello Ben,

Test Studio can automate the download of a PDF file or opening it in a browser, however is not able to  verify the contents or format of the PDF file itself. You can however leverage .NET to write coded steps that can work within your file system once the PDF is downloaded, however I cannot comment on what the effort in code would be or if additional libraries would be required to accomplish your goal.

Regards,
Daniel Levy
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Daniel Levy
Telerik team
answered on 18 Apr 2011, 10:29 PM
Hello Ben,

Test Studio can automate the download of a PDF file or opening it in a browser, however is not able to  verify the contents or format of the PDF file itself. You can however leverage .NET to write coded steps that can work within your file system once the PDF is downloaded, however I cannot comment on what the effort in code would be or if additional libraries would be required to accomplish your goal.

Regards,
Daniel Levy
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sebastien AUROUX
Top achievements
Rank 1
answered on 03 Nov 2011, 09:44 PM
and does it make a difference if the pdf report has been generated by telerik reporting ?
by that i mean, is it possible to make some verification to a telerik reporting (for example displayed on the web viewer)

it would be very great as our application output is mainly telerik reports.
sebastien
0
Anthony
Telerik team
answered on 03 Nov 2011, 10:13 PM
Hi Sebastien Auroux,

Unfortunately there is no difference. A PDF file loaded in the browser does not have a DOM structure like a traditional web page, so Test Studio cannot read or verify against its contents.

See the bottom of this page for more information and a suggested alternative.  

Best wishes,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sebastien AUROUX
Top achievements
Rank 1
answered on 04 Nov 2011, 08:37 AM
If I understand well the data driving feature is for the test studio to have a datasource it can perform tests against. but in the documentation example the data source file is static, we select it before running the test.

I dont understand how the test studio can perform a test where it can download a csv file (coming from a telerik report) and use that csv to perform verfication.

thanks for your help
sebastien
0
Anthony
Telerik team
answered on 04 Nov 2011, 02:41 PM
Hi Sebastien Auroux,

While dynamic data binding is not a built-in feature, you can use of one the solutions from our KB article on the topic. 

Greetings,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sandhya
Top achievements
Rank 1
answered on 23 Apr 2014, 05:11 PM
Can you tell me how I can automate if a report opens in a new browser. I do not want to verify the contents but just record a step that can prove that the report opened in a new browser window.
Sandhya
0
Boyan Boev
Telerik team
answered on 24 Apr 2014, 11:51 AM
Hello Sandhya,

Thank you for contacting us.

If you have configured/calibrated the browser properly every new report will be opened in a new window.

Here is an article about IE configuration.

You can verify that the number of elements in ​Manager.Browsers collection are more after opening the report.

Hope this helps. 

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Sandhya
Top achievements
Rank 1
answered on 24 Apr 2014, 03:53 PM
Hi
I checked to make sure my browser is caliberated properly. I ran my reports, but the Adobe reader opens with a dialog box. I have to close the dialog box to open the report in browser. I have attached the screen shots. My question is how can we automate this in test studio. Also do you recommend writing code when using test studio for issues like this.

Thank you
Sandhya
0
Boyan Boev
Telerik team
answered on 28 Apr 2014, 08:15 AM
Hello Sandhya,

Since this is not a web dialog, it can be automated only with coded step which simulates simple key presses.

Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);

This will press tab and enter once. Please make the right combination of the key presses to handle it.

Hope this helps.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Sandhya
Top achievements
Rank 1
answered on 28 Apr 2014, 06:31 PM
Thanks for your reply. I added this code to my test and now I am getting the messages
Reference required to assembly 'System.Windows.Forms, Version = 4.0.0.0 ....
I also tried to add reference to my project from project settings - > Script options screen but I don't find this assembly under C:/Drive telerik test studio Bin folder. I am not sure where else to look.
Could you also tell me why I should add this reference for the code to work.

Sandhya
0
Boyan Boev
Telerik team
answered on 29 Apr 2014, 08:14 AM
Hi Sandhya,

This is a Microsoft assembly, not a Telerik one.

It should be in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll on 64 bits machine.

Let me know if this helps. 

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Sandhya
Top achievements
Rank 1
answered on 30 Apr 2014, 05:47 PM
Thanks a lot. After adding reference to the assembly in my project the code is working.
Sandhya
0
Boyan Boev
Telerik team
answered on 01 May 2014, 06:19 AM
Hello Sandhya,

Glad to hear that!

If you need additional assistance, please let us know.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Andy
Top achievements
Rank 1
answered on 30 Mar 2017, 07:06 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.

Tags
General Discussions
Asked by
Ben
Top achievements
Rank 1
Answers by
Daniel Levy
Telerik team
Sebastien AUROUX
Top achievements
Rank 1
Anthony
Telerik team
Sandhya
Top achievements
Rank 1
Boyan Boev
Telerik team
Sandhya
Top achievements
Rank 1
Andy
Top achievements
Rank 1
Share this question
or