Yesterday, I encountered a strange phenomenon of qtp descriptive programming. The previous script suddenly failed to be verified. After several attempts, I finally found the rule, that is, there is an error in object identification in descriptive programming of qtp. If you have encountered this problem or have a good solution, please advise.
The crime scene is as follows:
Define the object with descriptive programming in the script
Verify whether the object exists and click this object to delete it. All operations here are normal.
Verify the deletion result and determine whether the object exists. The object still exists! (An error occurs here)
However, if you delete the object and verify whether the object exists, if you set another object, the object does not exist (correct)
The script is as follows:
Set OBJ = browser ("XX"). Page ("XX"). webelement ("innertext: = xx", "HTML Tag: = span ")
Msgbox obj. exist (2) -- true
OBJ. Click
OBJ. fireevent "oncontextmenu" -- Right-click the menu
Browser ("XX"). Page ("XX"). webelement ("Delete (d)"). Click -- delete
Msgbox obj. exist (2) -- true (error)
Set OBJ = browser ("XX "). page ("XX "). webelement ("innertext: = xx", "HTML Tag: = span") -- if you set it again, you can determine whether it is correct.
Msgbox obj. exist (2) -- false
If the preceding settings are not set again, the following methods can also get the correct results, indicating that the object recognition has an error.
Msgbox browser ("freequery "). page ("freequery "). webelement ("innertext: = qqq", "HTML Tag: = span", "index: = 0 "). exist (2) -- false
In addition, an object is set on a page. If you exit this page, you need to redefine the object even if it does not change. Otherwise, the object cannot be found.
I hope you can give me some advice on how to avoid this problem.