Micro Focus QTP (UFT) Forums
Negative Tests - Checking for links which should NOT be present. - 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: Negative Tests - Checking for links which should NOT be present. (/Thread-Negative-Tests-Checking-for-links-which-should-NOT-be-present)



Negative Tests - Checking for links which should NOT be present. - Kartal - 12-09-2010

I am total newbie and I am playing with QTP and I would like some help. I am running some tests on a website. The website has a logon with different classes of user. An "Admin" user has access to a host of links which enable the administration of the site, a "ReadOnly" user has a limited number of links available. Once logged in as a "ReadOnly" user how do I check that the links which are available to an "Admin" user are NOT available to a "ReadOnly" user ?

I have set up some standard checkpoints on the additional links when logged in as "Admin" but when I use these same checkpoint when logged in as "ReadOnly" it complains the object is not available.

What is the best way to test this scenario ?

Any help would be appreciated.


RE: Negative Tests - Checking for links which should NOT be present. - manishbhalshankar - 12-09-2010

You will have to use object.Exist to check if the perticular link object exist or not.


RE: Negative Tests - Checking for links which should NOT be present. - Kartal - 12-09-2010

Ok so how would I make the test fail ? For example the following link should NOT exist when logged in as "ReadOnly" user

Code:
Browser("My Web").Page("Reporting").Link("Update and Check").Exist

so how would I code it ?


RE: Negative Tests - Checking for links which should NOT be present. - Kartal - 12-09-2010

I resolved my problem

Code:
IF  Browser("My Web").Page("Reporting").Link("Update and Check").Exist(4) THEN
    reporter.ReportEvent micFail, "Admin Links", "Admin Links should only be available for Admins"
ELSE reporter.ReportEvent micPass, "Admin Links", "This is correct as no Admin Links are available"
END IF

I am using QTP 9.5, If anyone knows of a better way of doing this please let me know.

Thanks