Thursday, September 18, 2008

QTP Exist Method

If QTP is not able to identify an object due to any reason, start by using this Exist Method. This method returns false if an object does not exist. Use Exist method to check whether an object exists or not.

Open a new test and a Flight Reservation window.

Click Record and Fill in Date of Flight, Fly From and Fly To fields.

Click Stop in order to stop recording.

The code looks like this

Add one line as shown below and run the test again


It will show true. False is shown in case if the object does not exist, which helps in debugging if you get error like “cannot identify an object” or something like that.