Micro Focus QTP (UFT) Forums

Full Version: Null value of the object
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I am working on verifying the value of the object which is null.

The code as below:

Code:
gPostPrice = Browser("Market Reports - Price").Page("Market Reports - Price").WebEdit("priceEntry.priceEntryLines[3].poste").GetROProperty("value")
msgbox gPostPrice
If IsNull(gPostPrice)  Then
msgbox("entering if")
Else
msgbox("entering else")
End If

The value of the object is BLANK so I considered as Null (which I may be wrong)

Now, when I put the if condition, the msgbox with "entering else" is displayed.

What am I doing wrong? Please help..........
Hi,

Instead of checking for NULL, check for "" (Empty)

Here the working script

Code:
A = Browser("AS Login").Page("AS Login").WebEdit("uname").GetROProperty("Value")
If A = ""  Then
    Msgbox ("Working")
End If

Hope this Helps..........

Thanks,
Hi Swapna,
there are 2 ways how you can handle this.
Method1:
Code:
gPostPrice = Browser("Market Reports - Price").Page("Market Reports - Price").WebEdit("priceEntry.priceEntryLines[3].poste").GetROProperty("value")
if gPostPrice=Empty Then
   msgbox "pass"
else
msgbox "fail"
endif
Method2:
Code:
If gPostPrice=vbnullstring Then
   msgbox "pass"
else
msgbox "fail"
endif

Let me know if you need any more info on this.
Thanks,
QTPKing
Excellent Reply "supputuri 'SmileWink

- Sri, CAPM, CTFL
The conceptual idea is, Null and Empty are different. for exmaple consider "telephone_number" is a variable i have to assign the value. if its EMPTY means, i didnot asked the person for "telephone_number" so its EMPTY now, means value is not collected. Suppose that i asked the person about his "telephone_number" if he dont have any telephone means i can assign NULL to the "telephone_number".