Micro Focus QTP (UFT) Forums
How to validate blank field using QTP 11.00? - 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 validate blank field using QTP 11.00? (/Thread-How-to-validate-blank-field-using-QTP-11-00)



How to validate blank field using QTP 11.00? - newtester01 - 06-11-2012

Hi,

I am testing a web based application using QTP 11.00.
The application has a login page.
The login page has a text box with a "submit" button.
The name of the textbox is "username".

Question:

How to validate a blank field in QTP for the scenario below?

Scenario:
1. In Login page, do not enter any value for "username", click submit button.

Expected output in application:
Validation error is displayed "Please enter a username".


RE: How to validate blank field using QTP 11.00? - sshukla12 - 06-12-2012

Hi,

To check if txtBox is blank or not try the below code
Code:
valTXT=Browser(xx).Page(yy).webedit("userName").GetRoProperty("value")
if valTXT="" Then
'do something
else
Browser(xx).Page(yy).webedit("userName").Set ""
'to make field balnk
EndIF

Regards,
Sankalp


RE: How to validate blank field using QTP 11.00? - newtester01 - 06-13-2012

Hi,

I implemented the solution you suggested and it worked.

Thanks for your help.
newtester01


RE: How to validate blank field using QTP 11.00? - sshukla12 - 06-14-2012

Glad to hear it worked 4 u. Wink

Regards,
Sankalp