Micro Focus QTP (UFT) Forums
Null value of the 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: Null value of the object (/Thread-Null-value-of-the-object)



Null value of the object - swapna_gupta08 - 06-30-2009

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..........


RE: Null value of the object - QTPian - 06-30-2009

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,


RE: Null value of the object - supputuri - 07-08-2009

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


RE: Null value of the object - pun555 - 02-20-2012

Excellent Reply "supputuri 'SmileWink

- Sri, CAPM, CTFL


RE: Null value of the object - inborntester - 02-21-2012

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".