Results 1 to 4 of 4
  1. #1

    Check if an object does not exist


    I want to create a checkpoints which checks a webpage to make sure that an object (e.g. a button) does not exist.

    Can anyone please tell me how to do that? Currently what I can do with QTP checkpoints is to check properties of objects, not the objet existence.

    Many Thanks

  2. #2

    Re: Check if an object does not exist

    You need to code it
    <font class="small">Code:</font><hr /><pre>
    If Not ...WebButton().exist Then
    Reporter.ReportEvent micPass, "Does not exist","Does not exist"
    Reporter.ReportEvent micFail, "Does not exist","Does exist"
    end if
    </pre><hr />

  3. #3
    Advanced Member
    Join Date
    Mar 2007
    Salt Lake City, UT, USA

    Re: Check if an object does not exist

    Just a followup note.

    QTP Checkpoints are an OK place to start learning, but very soon, you will realize they are often too limited and too hard to maintain.

    Often, a much better solution is to do what Tarun proposed and use a method on your object, then evaluate that method in an If..Then statement, then report your findings.

    The benefits are manyfold.

    It's easy to update and maintain these values (you can put any expected results you want into your datatable and use those values in your If..Then to evaluate your test caes).

    You can easily customize a homemade checkpoint like this so that it reports whatever you want. You don't have to use strings as simple as Taruns - his are just samples. If you wish, those strings can be very long and complex, containing many meaningful variables and bits of information to help you diagnose what went wrong. Checkpoints are not this flexible.

    You can do many things inside of that If..Then. You are not limited to merely reporting pass/fail. In fact, you could put entire sections of your script here, so that (for example) if your WebButton exists, you run 100 lines of script, otherwise you run a different 200 lines of script. In fact, my scripts often are just a series of If..Then statements, one inside the other. Each time I do something important, I make sure it works, and I only continue the script if it does.

    In any case, study Tarun's example and consider any time you might want to insert a checkpoint. Ask yourself if you can write a homemade checkpoint that might give you more control - pretty soon you'll see the benefit of doing this all the time. I haven't used a QTP checkpoint in 5 years.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  4. #4



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:32 PM.

Copyright BetaSoft Inc.