Author Topic: Log Generation  (Read 1783 times)

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Log Generation
« on: February 26, 2009, 07:38:08 AM »
Hi

I have called external actions in an another Action( I am refereing it as Business Component Action) , now I want to log Pass/Fail inforamtion regarding the Business Component Action based on Pass / Fail state of the External Actions which constittues the Business Component Action.

For Example :
Launch is My Busines Component Action In which I am calling other 3 external Actions Launch_IE ,Click_English_Sign_On_link  and Click_OK_button [Click_]" . If any of these Actions failing I should fail Launch Business Componet Action Fail . I tired it with "Reporter.RunStatus" as shown below but it  is not correct because if the first Business Component Action  Fails in Your Dirver Scipt( which will inturn call a number of business Component Actions) then subsequent Business Component Action will be logged as fail though it is Pass . As "Reporter.RunStatus" will remain fail till the end of the Test if it fails once.

Any Ideas how to Log Pass /Fail result for the above said Scenario ?



Lunch ->

                      RunAction "Launch_IE [LaunchWebApp]", oneIteration

                      RunAction "Click_English_Sign_On_link [Click_]", oneIteration

                      RunAction "Click_OK_button [Click_]", oneIteration

                      if  Reporter.RunStatus = micPass Then
                         <Log Pass message >
                     else
                         <Log Fail message >
                      End if





Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3014
    • KnowledgeInbox
Re: Log Generation
« Reply #1 on: February 26, 2009, 08:50:55 AM »
There is one way to do it. That is to create a recovery scenario for Any Error and call a function. In that function you update a Environment variable named LastActionStatus

Environment("LastActionStatus") = "Fail"

Now your script would be something like below

Code: [Select]
     Environment("LastActionStatus") = "Pass"
                      RunAction "Launch_IE [LaunchWebApp]", oneIteration

Msgbox Environment("LastActionStatus")
Environment("LastActionStatus") = "Pass"

                      RunAction "Click_English_Sign_On_link [Click_]", oneIteration

Msgbox Environment("LastActionStatus")
Environment("LastActionStatus") = "Pass"

                      RunAction "Click_OK_button [Click_]", oneIteration

Msgbox Environment("LastActionStatus")

                      if  Reporter.RunStatus = micPass Then
                         <Log Pass message >
                     else
                         <Log Fail message >
                      End if

Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #2 on: February 27, 2009, 02:35:09 AM »
My intention is to log test result for business action based on external action Pass/Fail criteria as below:

As per your suggestions I have created a scenario but still it is Logging as Pass though I made my test to fail please   advised.

For your reference attaching code zipped file
Note: Extract it on desktop so that there won’t be problem with folder structure.


BusinessAction_01 ->>>>


Environment("strActionStatus") = "Pass"

'On error resume next

' Search For  string  "jabbar"
RunAction "Edit_Google_page [Edit_]", oneIteration

'Click Gogle Search Button on Google Page
RunAction "Click_Gogle_Search_button [Click_]", oneIteration

''Click 'Quick Test Professional link  ' on searched page
' Note :  We are searching for jabbar but trying to click on Quick Test Professional link so test will fail
RunAction "Click_Quick_Test_Professional_link [Click_]", oneIteration

' Message Should be displayed as Fail
msgbox " BusinessAction_01 Status: " & Environment("strActionStatus")




I have created a recovery scenario to trigger a call to executed a function which will set

Environment("strActionStatus") = "Fail"

Trigger Event for the Scenario is : Test Run Error
Test Run Error : Any Error
Recover Operation: Function Call
Post Recovery Operation: Proceed to next Action
Note 1: Function Written in Library as below

Function TriggerFailOnAnyError()
 Dim strActionStatus
 Environment("strActionStatus") = "Fail"
End Function



Note 2: Activate Recovery Scenario option (in File-> settings-> Recovery) is set to : On Error

Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3014
    • KnowledgeInbox
Re: Log Generation
« Reply #3 on: February 27, 2009, 03:33:27 AM »
How are you firing the recovery scenario?
Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #4 on: February 27, 2009, 04:21:14 AM »
Trigger Event for the Scenario is : Test Run Error

Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3014
    • KnowledgeInbox
Re: Log Generation
« Reply #5 on: February 27, 2009, 04:23:03 AM »
I am not asking about the trigger but what are you doing in the test which will simulate that event?
Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #6 on: February 27, 2009, 04:26:05 AM »
As I made the trigger : Test Run Error......... In my test I am click on a link which is not present on the gogle page.

Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3014
    • KnowledgeInbox
Re: Log Generation
« Reply #7 on: February 27, 2009, 04:28:59 AM »
Open the Recovery Lib and put a breakpoint inside the recovery function to make sure it is actually being called or not.
Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #8 on: February 27, 2009, 04:29:58 AM »
You can open "BusinessAction_01" test from the attached where you can see the code as

''Click 'Quick Test Professional link  ' on searched page
' Note :  We are searching for jabbar but trying to click on Quick Test Professional link so test will fail

RunAction "Click_Quick_Test_Professional_link [Click_]", oneIteration

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #9 on: February 27, 2009, 04:40:58 AM »
It is not getting called (recovery scenario is not getting triggered), when I uncomented On Error Resume next  statement.

If I comment 'On Error Resume next  ' then it will throw Run time error :


Cannot find the "Quick Test Professional(QTP)" object's parent "Google" (class Browser). Verify that parent properties match an object currently displayed in your application.

Line (15): "Browser("Google").Page("QTP - Google Search").Link("Quick Test Professional(QTP)").Click".

Tip: If the objects in your application have changed, the Maintenance Run Mode can
help you identify and update your steps and/or the objects in your repository.

Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3014
    • KnowledgeInbox
Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #11 on: February 27, 2009, 05:15:34 AM »
Tarun  gone through the article . My scenario falls under Situation #2. So is there any Remedy ?


Not only this kind of situation but even  if test fails for any of the  reason like validation failed , user not navigated to intended page .... etc . I should be able to log Business Action execution Result based on External Action end result. Please advise , your help is much appritiated.

thanks in advance!

--------------------------
Situation #2 - Object Not in Object Repository (OR)


If you try to access a object from the OR and it does not exist in the OR at all, then QTP will throw an error and RS won’t be fired. Object not found in object repository error is treated as a Script error by QTP and is raised directly.
------------------------

Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3014
    • KnowledgeInbox
Re: Log Generation
« Reply #12 on: February 27, 2009, 05:25:24 AM »
You cannot log such errors. You can though log errors when the objects is not found in the application. But it has to be there in the OR
Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0

Offline abduljabbarqa

  • Newbie
  • *
  • Posts: 19
Re: Log Generation
« Reply #13 on: February 27, 2009, 05:32:02 AM »
If it is the case then we wont be able to Log Test results for Business Actions !!!!!

There should be some way........ lets try to find solution

Thanks alot Tarun for all your help