Micro Focus QTP (UFT) Forums
MS One Note 2010 support from QTP 11.0 - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: MS One Note 2010 support from QTP 11.0 (/Thread-MS-One-Note-2010-support-from-QTP-11-0)

Pages: 1 2 3 4 5


RE: MS One Note 2010 support from QTP 11.0 - prachi.aug23 - 07-14-2011

Hi,

History repeated ! Now ,I am getting the Run error which I get very first time on line 25 .I have tried in both ways mentioned below :

Code:
returnedStatusCode = oShell.Run(pathToConversionUtil & " -NameOfPdfFile " & """" & nameOfPdfFile &"""" & " -ClearCacheFinally True -Output " &  """" & outputDirectoryForPrintedPdf & """" & " -CacheFolder " &  """" & temporaryCacheFolder &"""" & " -PagesAfterThisTime " &  """" & lastPrintedTime &"""" & "
-ShowTOC False -RefreshCache True", 0, True)
Code:
'returnedStatusCode = oShell.Run("""" & pathToConversionUtil & """" & " -NameOfPdfFile " & """" & nameOfPdfFile &"""" & " -ClearCacheFinally True -Output " &  """" & outputDirectoryForPrintedPdf & """" & " -CacheFolder " &  """" & temporaryCacheFolder &"""" & " -PagesAfterThisTime " &  """" & lastPrintedTime &"""" & "
-ShowTOC False -RefreshCache True", 0, True)

Log file I can send you by EOD . If I skip this run error , it opens Adobe but doesn't open the printed expected page from the application ,gives:
"Error opening document . File not found ."

Thanks,


RE: MS One Note 2010 support from QTP 11.0 - Light - 07-14-2011

Lol!

Are we back to square 1!

Can you add a watch to the whole expression inside oRun. Shell, copy the value and send it across?

If you got run error, then the utility wasn't even invoked so I don't think there will be a log.

It's most likely an issue within the script.


RE: MS One Note 2010 support from QTP 11.0 - prachi.aug23 - 07-15-2011

I ran the same script today and it worked ! Finally!

Time is a problem here though .
It took around 1 hour to convert OneNote to PDF for 2568 pages .
It printed pages from 19.5.2011 till date . I thought it will print just for today,15.7.2011 .Did I miss something to update in the script .

The pdf doc is open now , it shows the content upto 1568 pages , rest of the pages still loading for almost an hour .Its stuck after 1568 pages .

While running script , I got the message box as "0" , meaning success!
Now,I should again get a message box for :Was the PDFOkay? , which I didn't get yet almost 3 hours from the printing and script is still running.
I think its waiting for the content to be displayed in all 2568 pages.But isn't it a long time?

I closed the PDF and then it showed the message box :Was the PDFOkay? I clicked yes . Also, I do not see any log file generated this time.

Moving ahead a next step ,as you mentioned in your very first post about what to do once PDF is generated , my thoughts---:

1. To manually see it and then decide whether the checkpoint passes or fails? [One Manual Step] ---Manually we can see in One Note too , so skipping this option .
2. To just attach it somehow to the Report Results for archival and bug reporting? [Auto] ---As per my understanding , we attach the PDF to results , but verification part is again manual . And since there are many print actions , so if we verify the PDF at one shot , its time taking to first get the reference to the test it corresponds to and then verifying the data .
3. To automatically look for a specific string in the pdf to ascertain the success of the checkpoint? [Auto] --This is best approach once it is implemented .It allows to know the pass/fail status merely looking at the test result report .No debugging and no manual verification required.

Thanks again for all your efforts and time.


RE: MS One Note 2010 support from QTP 11.0 - Light - 07-15-2011

Wow! I'm so glad and grateful!

You have been incredibly patient while the utility did its job. And the number of pages and hours it took just shocked me.

Now, what you thought was perfectly right. It should have exported just those pages that your application printed seconds before the utility was invoked.

To ascertain why that did not happen, we first need to know what date was passed to the utility.

Did you, by any chance, manually update the value of the variable lastPrintedTime in the script for the action? It's supposed to remain CStr(Now). And the time should be captured exactly before the action for printing the pages is invoked.

This means that your "Printing Action" must be invoked in the next statement after the time is captured. Another important thing is that you should actually wait for the "Printing Action" to finish before proceeding. Did you notice if that's happening?

We'll need to examine the log. Where are you looking for the log file? If the config file I sent you is in the same folder as the utility, then the log will definitely be generated in the same folder. But, if the log file already exists, data will be appended in it. Can you send me the log file from that folder? Zip it if needed. In any case, can you capture the value of the expression inside oShell.Run? You don't have to wait for the whole thing to finish. Just put a breakpoint on line 25. Add a watch to the expression, copy the value and stop the script. I'm only interested in what was passed to the utility.

As for the huge amount of time it took, that happened only because of some date issue. Normally, it wouldn't take this long as I assume your application may not be printing these many pages. Right?

The message box that says "Was the PDF okay?" will always come when you manually close the pdf in the current scenario. This is so because the script doesn't know whether you have thoroughly looked at the pdf. When you close the pdf, then only the script proceeds asking you if it was okay. This is by design so nothing to worry here.

Going by the choice that you've indicated about what to do once the pdf is generated, we'll make this script completely "silent." No message boxes, nothing. It'll just create the pdf, examine it and update the results, all without you moving a finger. But, this requires that your machine has either Adobe Acrobat Standard or Professional installed.

Can you check if this is so?

I'll enhance this script so it automatically examines the pdf for the presence of a "Success word" or a "Failure Word."

By jove, I'm very happy today!

Cheers,
Light.


RE: MS One Note 2010 support from QTP 11.0 - prachi.aug23 - 07-15-2011

Hi Light ,

I will surely check all required details , but I can do so on monday now Smile
I don't have adobe acrobat standard or professional in my system .
I will raise a request for one of these ,though it's going to take a while.
Meanwhile , I check the details and send you the results.

Few of the questions I can answer now, hope it makes sense:

Did you, by any chance, manually update the value of the variable lastPrintedTime in the script for the action? ---No, no manual update .

Another important thing is that you should actually wait for the "Printing Action" to finish before proceeding. Did you notice if that's happening? ---I think printing action was complete , before the next line execution started. Though I am not 100% sure .Need to keep eye on it next time.

We'll need to examine the log. Where are you looking for the log file? --yes. all the files,utility are in same folder. Last time the log file saved at same location(same folder where all other files are) . I have deleted the last log before re-running the script .Could that be a problem?

Normally, it wouldn't take this long as I assume your application may not be printing these many pages. Right?-----The application doesn't have this much data for 1 run. But as the OneNote section 4 where all the printed page exist ,keeps appending the data . So, it is huge and it will grow with every next run .
Even if I delete this OneNote and run the script, it saves the last printed page after all the prints done earlier in section 4 .

Thanks,



RE: MS One Note 2010 support from QTP 11.0 - Light - 07-18-2011

Hello. Smile

We'll first fix the issue around the date and only then we'll introduce any new changes for the next step. Apart from other things, please also tell me how the date and time looks like on your system clock usually displayed at the bottom-right corner. I need the exact formatting.

To answer your question:

You said you deleted the log file before re-running the script, which is fine. The file should be regenerated in the same folder.

Also, how are you actually printing the things? Is there a way to "force wait" until the print operation finishes? So, when this action is resumed after "Printing Action", we're always sure that the printing had actually been finished.

I've tried many things for the next step i.e. searching for a "success word". It is proving to be much more challenging and unreliable than I had expected.

First, as soon as your application prints anything, it becomes a graphic even when it looks like text so we can't search for a "success word" until we OCR (Optical Character Recognition) the graphic through some means.

I tried running the OCR on the pdf that we're generating but that fails because OneNote only publishes the graphic, which is not an image (e.g. JPG, PNG, BMP, TIFF etc.). OCR can only be done on some kind of image.

To work around that, I modified the OneNote2Pdf utility such that it converts the graphic from OneNote into Tiff (image format) and then re-creates the pdf so it now contains Tiff images of the pages printed by your application. Now, we can run the OCR on the PDF.

But, there are two problems:

1. Adobe Acrobat Professional doesn't allow performing OCR programmatically from outside (QTP, .NET, Java, etc.)

2. There are tools (QTP internally uses ABBYY FineReader) that can do this job but they all will cost your company some money. So, I tried an open source tool: Tesseract which didn't do a very good job on my prints so it affected my confidence in Third-Party OCR tools. There's one Puma.NET tool as well with which I haven't experimented too much. I'd do so in coming days.

In a bid to solve the first problem, I tried to use QTP's declarative programming to automate OCR as if a user was doing it in Adobe Acrobat. Through this, I could successfully capture the text from the PDF but it bloated our Results Window with all those actions that were performed by QTP on Adobe Acrobat Professional window. After getting the text from pdf, I used InStr function to check for the presence of a "success word." It worked fine, indeed. How do you feel about this solution?

There is yet another way left, which is to first write a small Acrobat Professional plug-in in C++ language, which will invoke the OCR on the pdf. We'll expose this plug-in as a COM interface, which will then be callable from QTP script. The only reasons why I didn't write this yet is because I've forgotten C++ programming and reading Adobe documentation is a pain in the neck. Smile But, if you think the DP solution isn't elegant, I'll attempt to resurrect my C++ compiler. This one is also the recommended solution by Adobe.

Thanks,
Light.


RE: MS One Note 2010 support from QTP 11.0 - prachi.aug23 - 07-19-2011

Hi ,

Here is the value details for oshell :

NameOfPdfFile
"OneNote2"

pathToConversionUtil
"C:\Documents and Settings\username\Desktop\OneNoteAll\OneNote2PDF.exe"

outputDirectoryForPrintedPdf
"C:\DOCUME~1\username\LOCALS~1\Temp\3\TempResults\PdfDocs"

temporaryCacheFolder
"C:\DOCUME~1\username\LOCALS~1\Temp\3\TempResults\PdfCache"

lastPrintedTime "19.7.2011 8:29:11"

oshell
methods: no value
Current Directory:
"C:\Documents and Settings\username\Desktop\OneNoteAll\OneNote2"

env:{...}
special folders : {...}

Date format in my m/c : Day,Month Date, Year
eg. Tuesday, July 19, 2011

Log file again isn't generated .

Thanks,


RE: MS One Note 2010 support from QTP 11.0 - Light - 07-20-2011

Hello.

Thank you. I used your values and ran the utility in Debug mode. I noticed that .NET DateTime structure couldn't parse the date and time in the format that QTP supplies to the utility in your system.

Earlier, I had believed that QTP also will use the same date time format as your system date and time but it appears that they are not the same. The funny thing is that here on my system QTP utilizes the same date/time format as my system and .NET, hence I never saw this issue.

I think the safest bet is to utilize DotnetFactory here. Can you replace Line 13 where we're assigning CStr(Now) to the variable: lastPrintedTime with two lines that I pasted below?

Set dotNetDateTime = DotnetFactory.CreateInstance("System.DateTime")
lastPrintedTime = dotNetDateTime.Now


Also capture the value as it goes this time.

If you see the value is still being passed the same way as before, then consider using the following lines instead:

completeDate = year(Date) & "-" & month(Date) & "-" & day(Date)

lastPrintedTime = completeDate & " " & Time


What still perplexes me though is the fact that on 15th July, the utility exported almost all the pages in your notebook beginning from 19th May! Now, I couldn't link 19th May 2011 and 15th July 2011 at all. Have you got any idea about this? According to the code, it shouldn't have exported a single page because .NET couldn't parse the date at all.

And another puzzle is the generation of log file. Can you check if the file OneNote2PDF.exe.config which exists in the same location as the utility itself has the following key/value pairs?

1. <add name="DataMessagesSwitch" value="1" />
2. <add name="TraceLevelSwitch" value="4" />

When you ran the script this time, did you allow the utility to run to finish? Or, you just put the breakpoint on Line 25, captured the values of variables and stopped the script? Remember the log will only be available if the utility was really invoked and allowed to run for some time.

Please also make sure that the folder where you've placed the utility and the config file isn't read-only and that you have write permission on the folder.

I'd wait for your observations.

Thanks,
Light.


RE: MS One Note 2010 support from QTP 11.0 - prachi.aug23 - 07-20-2011

Hi,

For some reason , I am again getting this error with no change in script :
"Onenote2PDF detected error and product is closed."
Error code same as earlier one:-1073741819

Using the format and adding watch, below are the values obtained :
completeDate = year(Date) & "-" & month(Date) & "-" & day(Date)

returnedStatusCode=-1073741819
completeDate= "2011-7-20"
lastPrintedTime= "2011-7-20 12:37:25"

I checked OneNote2PDF.exe.config , values are same like you mentioned. Log file is generated this time ,I will send you in mail.

Regarding,the utility exported almost all the pages in your notebook beginning from 19th May! As per my understanding:
If I give a print now, it goes to the same section of OneNote and appends the data to existing OneNote content .It doesn't create a new OneNote or section everytime So for a print on 20.7.2011 , the complete data ,right from day 1 usage of OneNote (19th May) opens and when the CStr(Now) checks ,it checks for the recently opened OneNote ,which is again the complete data . I may be wrong , but I think if we can give the new print everytime in new section it may print just the required content.

Thanks,



RE: MS One Note 2010 support from QTP 11.0 - Light - 07-20-2011

Hi.

Yeah, please send me the latest log file. It'll hopefully uncover some interesting clues into why it stopped working this abruptly. It started abruptly and stopped abruptly too. Smile

While waiting for the newest log file, I decided to take a closer look at the log file you sent me on 13th July. Before I go into details, I have a question:

Does your application open OneNote application while printing pages and leave it open even after the printing is finished?

And, while running the script, are you manually navigating across the OneNote sections and pages for some reason?

OneNote shouldn't be touched at all after printing pages and before our utility returns the status code to the script. The reason is that doing so may fudge the lastModifiedTimes of sections and pages. This timestamp is the very fulcrum of our algorithm.

Here are my observations from the log file:

Date & Time passed in: 12.7.2011 8:04:00 (2011-07-12 08:04:00)

1. Notebooks updated on 12th July:
a. Personal (10:34:15)
b. Desktop (10:24:35)
c. Rtaks (10:24:35)

2. Sections updated on 12th July:
a. Section4 in Personal (10:34:15)

3. Pages updated on 12th July:
a. Untitled Page in Section4 (10:34:15)

Now, the utility follows this sequence of steps:

1. Retrieve information about ALL pages in OneNote.

2. Then, take each notebook one at a time and do the following:

a. Proceed to (b) if the lastModifiedTime of at least one section in this notebook is later then what we passed in. Otherwise, go to Step 2.

b. Take each page in this section one at a time and do the following:

i. If the page's lastModifiedTime is later than what we passed, then publish the page as a pdf file in cache folder. Otherwise, simply skip it and go to Step 2 (b).

3. At this stage, we have each newer page in its own pdf in the cache folder.

4. Combine them all in one PDF and put that in the output folder.

Now, if the date and time were passed in properly, then

1. Notebooks that have at least one section modified later than what we passed in: Personal

2. Section that was modified: Section4

3. Page that was modified: Untitled Page

The resultant PDF would have had just one page and that is Untitled Page.

All of this looks okay to me. Your application printed only one new page in Section4 in Personal notebook on that day, which is okay.

I have just one question: Did you really start the script at 08:04:00 A.M on that day? Is this the correct date and time?

If so, then the timestamps suggest that it took around 2.5 hours to print pages. This doesn't look normal. What do you think? This makes me feel that OneNote was being used while our utility was doing its job, which is an issue.

Coming back to your guess of why it may have taken all the pages from 19th May:

1. It doesn't check the last opened time but lastModifiedTime. Again, if something is opening OneNote and modifying something in there then these two timestamps could be the same, but our algorithm can never handle that.

2. And, to make this work, all we need is a new page under any section under any notebook that has the lastModifiedTime AFTER the date and time we pass in. We don't really need a whole new section or a whole new notebook; just a whole new page or a collection of them anywhere in OneNote.

I thought I'd write this before I got a chance to look at the latest log so as to clear up any confusion around the algorithm the utility is following.

We'll discuss again after I run through the log file you'll send.

Cheers,
Light.