07-22-2013, 01:58 PM
That's correct we cannot print a method action.The code returns general error though print is excluded in the second iteration as the reference is lost due to Browser().back.
Here is a small demo to justify this statement.
Each QTP object has a hidden method "Init" to reinitialize the object cashe. Using Init on the object makes sure that it is re-identified.With QTP 11, new method "RefreshObject" has been introduced.
Here is a small demo to justify this statement.
Code:
Set oPage=Browser("name:=Google").Page("title:=Google")
Set oSearch=oPage.WebEdit("name:=q")
Set oSearchButton=oPage.WebButton("name:=Search")
oSearch.Set "Learn QTP" 'runs fine without any error
Browser("name:=Google").Refresh 'or back..
oSearch.Set "Learn QTP" 'throws error
Code:
Set oPage=Browser("name:=Google").Page("title:=Google")
Set oSearch=oPage.WebEdit("name:=q")
Set oSearchButton=oPage.WebButton("name:=Search")
oSearch.Set "Learn QTP" 'runs fine without any error
Browser("name:=Google").Refresh
oSearch.RefreshObject 'reinitializing the object 'oSearch'
oSearch.Set "Learn QTP New" 'runs fine without any error