Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8798455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:06:02+00:00 2026-06-14T00:06:02+00:00

I am a QTP neophyte. I’m able to write statements like this, using the

  • 0

I am a QTP neophyte.

I’m able to write statements like this, using the Object Repository:

If Trim(DataTable.Value("ExpectedValue")) = "" _
  And Not Browser("MyApp").Page("MyPage").WebElement("MissingDataBanner").Exist  Then
    Reporter.ReportEvent micFail, "MissingDataBanner", "Element expected"
End If

While I can use descriptive programming to check properties of elements that do exist…

If Not Browser("MyApp").Page("MyPage").WebElement("text:=" + DataTable.Value("ExpectedValue")).Exist Then
  Reporter.ReportEvent micFail, "My Data Field", "Element does not contain expected value"
End If

when I try something like this:

If Trim(DataTable.Value("ExpectedValue")) = "" _
  And Not Browser("MyApp").Page("MyPage").WebElement("text:=" + DataTable.Value("ExpectedValue")).Exist  Then
    Reporter.ReportEvent micFail, "MissingDataBanner", "Element expected"
End If

of course QTP can’t find the web element, and the test errors trying to access the Exist method.

Is there a way to use descriptive programming to check that an element does NOT exist on the page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:06:03+00:00Added an answer on June 14, 2026 at 12:06 am
    1. take a look at the first if statement and particulary this line: If Trim(DataTable.Value("ExpectedValue")) = "". You are saying ‘If ExpectedValue is empty And the object does not exist, then report an error’ Is that really what you want or do you want to test the ExpectedValue on ‘not empty’: If Trim(DataTable.Value("ExpectedValue")) <> ""?

    2. Concatenation in VBScript is done with a & sign and not with a +, This statement Browser("MyApp").Page("MyPage").WebElement("text:=" + DataTable.Value("ExpectedValue")).Exist will resolve to Browser("MyApp").Page("MyPage").WebElement(0).Exist, leading to unexpected results. Use "text:=" & DataTable.Value("ExpectedValue") instead.

    3. QTP has some quirks, testing on .exist property on objects is one of them (I am speaking for QTP10 here). It sounds strange, but in some cases (unfortunately I can not remember which once, if I have a spare minut I’ll try to reproduce it), .exist returns a False that is not recognized natively as False in a conditional statement. The best way to test if an object does not exist is explicitly test if the exist property equals false: If Browser("foo").Page("bar").WebElement("xizzy").exist = False then print "Object does not exist!).

    4. tip: To speed up your test, you can use the exist with a timer, if you use .exist(0) it will test the existence of the object immediately with no use of the synchronization timers you have set in your testsettings.

    Maybe this is not directly a solution to your exact problem, but it gives more reliable results and will eventually lead you to the solution. Testing if an object does not exist with the .Exist method is the correct way to do this. When you are getting errors there is something else wrong. For example the browser or the page does not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know whether the QTP is able to select object of
i am trying to write a script in qtp like this Public Function sayhi
Not using QTP myself, but trying to answer this question , I desperately need
for whom using QTP(Quick Test Professional) do anyone of you face this issue on
QTP which access an application object in test PC screen resolution doesnt access the
Basic doubt...If QTP generates vbscript code as we record actions, can't we directly write
I'm using QTP 10 together with VMWare to test a Siebel Application. I'm executing
I'm trying to test using QTP a web app that is using ajax4jsf to
How can i compare two rows of datatable in QTP
I have a QTP script that interacts with a webpage. Occasionally, this webpage will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.