Automating QTP Test Automation Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map
Gotchas - True is not always TrueThe Boolean constant for 'True' has the numeric value -1. Historically, this is because the Boolean data type is stored as a 16-bit signed integer and -1 is 16 binary 1s (the Boolean value False is 16 0s). This definition of True comes from the Microsoft implementation of BASIC in the early 1970s. Unfortunately, while the QTP definition of boolean False is zero, the definition of True is NON-ZERO. In the case of the return from Browser("Browser").Page("Page").WebEdit("test").Exist(0), the value returned (if true) is +1. So while: If Browser("Browser").Page("Page").WebEdit("test").Exist(0) Will work as expected, If Browser("Browser").Page("Page").WebEdit("test").Exist(0) = True Will ALWAYS evaluate as FALSE. |