Micro Focus QTP (UFT) Forums

Full Version: PASS/FAIL in QTP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Let me explain the problem using an example. Lets say I have to validate a login functionality in a web page. Login is success for "login" and "passwd123" user credentials and for rest throws error message.
In the script using Data Driven I try to login using various users. For a valid user, on login success I check the text and if exists I report a message with PASS else FAIL.

Now my question is when I manually execute this test case, when the valid user is allowed to login and for the rest it throws a message. I PASS this test case.

when I run this data driven script with same logic, the QTP summarized result shows FAILED though the script completed successfully.

what is the correct approach. How to go about handling PASS/FAIL in QTP script.
Hi Badri,

Are you using the conditional statements and then using QTP Pass/Fail?

It should be some thing like
Code:
if (this error message display) then
    QTP pass
else
    QTP Fail
end if
Thats fine..I am using the same way. But try to understand my question.

when i execute the testcase for various users(valid n invalid), the manual test case is PASS.
Similarly, when i run as automated, how should i handle the logic for PASS/FAIL.
Code:
'Valid user name and password
  username = "abc"
  password = "def"

Call Login("Valid",username,password)

'InValid user name and password
  username = "xyz"
  password = "pqr"

Call Login("InValid",username,password)

'Login Function
Function Login(strValidation,UN,PWD)

if strValidation = "Valid" then
   'code to validate successful login
elseif strValidation = "InValid" then
   'code to validate failure login
end if

End Function