Screenshots missing in log entries when using try-finally

Class library usage, coding and language questions.
lyn5000
Posts: 50
Joined: Mon Feb 13, 2012 5:52 pm

Screenshots missing in log entries when using try-finally

Post by lyn5000 » Tue Nov 06, 2012 12:43 am

In the test module's "ITestModule.Run()" method I have this code (pseudo) -
//Open IE9 to my page
//Validate.Exists("a path to an element that exists")
//Validate.Exists("a path to an element that does not exist")
//Clean-up: clear IE9 browsing history (Only "Temporary Internet files" and "Cookies" checked in IE's Delete Browsing History)

When the case has finished, log correctly shows:
1 Success Validation (shows screenshot including browser)
2 Failure Validation (shows screenshot including browser)
3 Error Module (shows screenshot including browser)

However if I put the code in try-finally sections as follows (because I want the finally block to always execute to clean-up my test even if it fails in the middle of the test):
try
{
//Open IE9 to my page
//Validate.Exists("a path to an element that exists")
//Validate.Exists("a path to an element that does not exist")
}
finally
{
//Clean-up; clear IE9 browsing history (Only "Temporary Internet files" and "Cookies" checked in IE's Delete Browsing History)
}

Then in the log the same entries exist as in the first example above but the screenshots are missing from log entries 1 and 2 (just shows the message entry for 1 and 2 in the log but the screenshot for each is missing).

I guess this is something to do with the way ITestModule.Run() works but I don't understand why the log entry is made without the screenshot.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Screenshots missing in log entries when using try-finally

Post by Support Team » Tue Nov 06, 2012 1:05 pm

Hi,

There shouldn't be any screenshots in the report file if you just used "Validate.Exists(String RxPath)" and if the validation was successful.
If the validation would fail there would be screenshots or if you would explicitly set it in the Validate Options parameter of the Exists method.
Could it be that you set it in the Validate Options?
Which of the overloaded methods was used?
Which Ranorex version is in use?

Regards,
Markus
.
Image

lyn5000
Posts: 50
Joined: Mon Feb 13, 2012 5:52 pm

Re: Screenshots missing in log entries when using try-finally

Post by lyn5000 » Tue Nov 06, 2012 6:49 pm

Example below. Not using Validate.Options.
Ranorex 3.3.3.

Code: Select all

try
{	            
   Host.Local.OpenBrowser("ranorex.com","ie",true,true);	          
   //Validate go button
   Validate.Exists("/dom[@domain='ranorex.com']/body/div[@id='page']/div[@id='Header']/div[@id='top-nav']/div[@id='top-menu']/div/form/input[@type='submit']");
   //Validate something that I know will fail
   Validate.Exists("/dom[@domain='ranorex.com']/div[@id='thisdoesnotexist']", new Duration(3000));
}
finally
{
   //Call method to clear IE9 browsing history (Only "Temporary Internet files" and "Cookies" checked in IE's Delete Browsing History dialog)
}
After running, in the report (rxlog):
- The first Validate.Exists is successful and shows:
A screenshot together with "Element for path '/dom[@domain='ranorex.com']/body/div[@id='page']/div[@id='Header']/div[@id='top-nav']/div[@id='top-menu']/div/form/input[@type='submit']' does exist. "
- The second Validate.Exists fails and shows:
A screenshot together with "Element for path '/dom[@domain='ranorex.com']/div[@id='thisdoesnotexist']' does not exist (No element found for path '/dom[@domain='ranorex.com']/div[@id='thisdoesnotexist']' within 3000ms.). "
- Then the final log entry shows:
A screenshot and "Module execution was aborted because a validation step has failed. Element for path '/dom[@domain='ranorex.com']/div[@id='thisdoesnotexist']' does not exist (No element found for path '/dom[@domain='ranorex.com']/div[@id='thisdoesnotexist']' within 3000ms.). "

If you remove all of the code in the finally block and rerun, the exact same entries appear in the log but with the screenshots missing.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Screenshots missing in log entries when using try-finally

Post by Support Team » Wed Nov 07, 2012 5:51 pm

Hello,

Unfortunately we are not able to reproduce this issue. In our case the screenshots are available in both scenarios.
As workaround you could use Report.Screenshot() to get screenshots in your Report as shown below:
Report.Screenshot(ReportLevel.Info, "User", "", repo.RanorexTestPage.Self, false);
Is it possible to send us the solution in order to reproduce this issue?

Regards,
Bernhard
.
Image