Micro Focus QTP (UFT) Forums
How to Verify a Non Existing Object - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to Verify a Non Existing Object (/Thread-How-to-Verify-a-Non-Existing-Object)



How to Verify a Non Existing Object - rock111 - 12-01-2011

Hi,

I have a Menu which is displayed when i hover the mouse on it.
It displays a list of menu options depending on the user permissions.

My scenario is to check if a particular menu option is not displayed for a user.
I'm trying to use the below line of code to check the option is not present for the user.

Code:
Browser("IE").Page("Page").Link("ABC").Exist

But it throws an error message since the object was not found in the object repository.

How do i handle this scenario?


RE: How to Verify a Non Existing Object - ravi.gajul - 12-01-2011

Get all the links displayed in an array and compare the text property of the required link with the links fetched.You may use child objects method to get all the links.
for ex:
Code:
set allLinks=Browser().Page().childobjects(<Linktype>)
for i=0 to allLinks.length-1

If allLinks(i).getRoProperty("innertext")="ABC" then
msgbox "Link Exists"
Else
msgbox "link doesn't exist"
End If
Next

Regards,
Ravi



RE: How to Verify a Non Existing Object - anil2u - 12-01-2011

Hi

I had faced a similiar issue. Usually such drop-downs are identified as webtable by qtp. check for that. If its a webtable its further easy for u to get the child objects from the webtable using what ravi suggested

Code:
like Browser(Browser).Page(Page).webtable(webtable).childObjects

Anil