How to verify PDF content which opened in pdf application

110 views
Skip to first unread message

santosh kawade

unread,
Aug 28, 2015, 3:57:04 AM8/28/15
to seleniu...@googlegroups.com
Hello all,
I am running selenium test in IE.
On Button click I am getting download menu bar 
Which having three buttons as Open, Save and Cancel.

Once I clicked on Open button
PDF is opened into application

How to verify the pdf content??

please let me know if any..


Thanks
Santosh 

Krishnan Mahadevan

unread,
Aug 28, 2015, 4:03:28 AM8/28/15
to Selenium Users
Santosh,

Please take sometime to read through this blog post that Mark Collins wrote up : http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

After that you would perhaps want to just use a library such as pdfbox to verify the contents

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CABqZg2xOQ34DQeJ6f_Q65O4UHchNeQJ7m3BkqLX%2Bi6KvrycM5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

santosh kawade

unread,
Aug 28, 2015, 4:19:29 AM8/28/15
to seleniu...@googlegroups.com
Thanks Krishan  for quick reply 
Let you know is this work for me or not.

Thanks


santosh kawade

unread,
Aug 28, 2015, 4:45:19 AM8/28/15
to krishnan.ma...@gmail.com, seleniu...@googlegroups.com
Hello krishanan
I go through the blog. Its  mainly related to download file and verify.
My workflow is different. I am not downloading file. 
It open in file in application when I click on open button from download menu 


Thanks
Santosh 

On Fri, Aug 28, 2015 at 1:33 PM, Krishnan Mahadevan <krishnan.ma...@gmail.com> wrote:

mr. Selenide

unread,
Aug 28, 2015, 1:49:13 PM8/28/15
to Selenium Users

Hi!
+1 to Krishan. Download the file separately and use a dedicated library to test PDF content. 

Let me recommend library "pdf-test" for this. It has a convenient API for testing PDF:
    PDF pdf = new PDF(new File("src/test/resources/50quickideas.pdf"));
    assertThat(pdf, containsText("50 Quick Ideas to Improve your User Stories"));


пятница, 28 августа 2015 г., 10:57:04 UTC+3 пользователь santosh написал:

Mark Collin

unread,
Sep 3, 2015, 4:59:42 AM9/3/15
to Selenium Users, krishnan.ma...@gmail.com
You are downloading the file to open it.

What you missed when you read the blog is that you do not need to open the file to check that it is correct, you just need to get an MD5/SHA1 hash of a known good file and compare it to the  MD5/SHA1 hash of the file you downloaded.  If they are the same the correct file was downloaded.  If they are different the file you downloaded is not what you thought it was.

You could write code to diff a PDF but is it really worth it, That's a lot of work for minimal benefit.  If you save the file that is incorrect you can manually verify the differences (if you care). 


On Friday, 28 August 2015 09:45:19 UTC+1, santosh wrote:
Hello krishanan
I go through the blog. Its  mainly related to download file and verify.
My workflow is different. I am not downloading file. 
It open in file in application when I click on open button from download menu 


Thanks
Santosh 
On Fri, Aug 28, 2015 at 1:33 PM, Krishnan Mahadevan <krishnan.mahadevan1978@gmail.com> wrote:
Santosh,

Please take sometime to read through this blog post that Mark Collins wrote up : http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

After that you would perhaps want to just use a library such as pdfbox to verify the contents

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Fri, Aug 28, 2015 at 1:26 PM, santosh kawade <kawade...@gmail.com> wrote:
Hello all,
I am running selenium test in IE.
On Button click I am getting download menu bar 
Which having three buttons as Open, Save and Cancel.

Once I clicked on Open button
PDF is opened into application

How to verify the pdf content??

please let me know if any..


Thanks
Santosh 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

santosh

unread,
Sep 3, 2015, 8:07:10 AM9/3/15
to Selenium Users, krishnan.ma...@gmail.com
Hello Mark,
My test scenario is like 
Once I click on download button IE open download window
which showing three buttons as Open, Save and Cancel.
Then I have to click On Open button.
Once I clicked on Open button One PDF file is opened which not saved on local drive
And I want t verify this file
Please let me know if this is possible


Thanks
Santosh Kawade

On Thursday, 3 September 2015 14:29:42 UTC+5:30, Mark Collin wrote:
You are downloading the file to open it.

What you missed when you read the blog is that you do not need to open the file to check that it is correct, you just need to get an MD5/SHA1 hash of a known good file and compare it to the  MD5/SHA1 hash of the file you downloaded.  If they are the same the correct file was downloaded.  If they are different the file you downloaded is not what you thought it was.

You could write code to diff a PDF but is it really worth it, That's a lot of work for minimal benefit.  If you save the file that is incorrect you can manually verify the differences (if you care). 

On Friday, 28 August 2015 09:45:19 UTC+1, santosh wrote:
Hello krishanan
I go through the blog. Its  mainly related to download file and verify.
My workflow is different. I am not downloading file. 
It open in file in application when I click on open button from download menu 


Thanks
Santosh 
On Fri, Aug 28, 2015 at 1:33 PM, Krishnan Mahadevan <krishnan.ma...@gmail.com> wrote:
Santosh,

Please take sometime to read through this blog post that Mark Collins wrote up : http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

After that you would perhaps want to just use a library such as pdfbox to verify the contents

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Fri, Aug 28, 2015 at 1:26 PM, santosh kawade <kawade...@gmail.com> wrote:
Hello all,
I am running selenium test in IE.
On Button click I am getting download menu bar 
Which having three buttons as Open, Save and Cancel.

Once I clicked on Open button
PDF is opened into application

How to verify the pdf content??

please let me know if any..


Thanks
Santosh 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Mark Collin

unread,
Sep 3, 2015, 9:38:08 AM9/3/15
to Selenium Users, krishnan.ma...@gmail.com
It is saved to your local drive.  It has been saved in a temp directory which is where another application is reading it from to be able to display it to you.

Clicking open really means:

* Save to my local drive in a temp folder.
* Open the PDF I have saved in the temp folder with the application my OS has associated with PDF files.

If you go back through that blog post it will tell you how to programatically save the file to disk and perform an SHA1/MD5 hash check on it to check that it is the correct file.

santosh

unread,
Sep 7, 2015, 6:30:34 AM9/7/15
to Selenium Users, krishnan.ma...@gmail.com
Hi Mark
Thanks for update.


Thanks
Santosh Kawade
Reply all
Reply to author
Forward
0 new messages