Forum Discussion

thustead's avatar
thustead
Contributor
13 years ago

If Object Exists test action not working

I have an "If Object Exists" test action in a keyword test that doesn't always work correctly.  If the object its looking for doesn't exist it still executes the child operations.  I have this in a few tests, some work and some don't.



Any suggestions?



Thanks,

Tom

9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    It's possible that the object you are referencing within the "Object Exists" check is being mapped in such a way in NameMapping that you might be "finding" an object but it might not be the object you are looking for.  Double check the mapping criteria for the object and make sure it is being referenced in such a way as to not be ambiguous with something else.
  • I think the mapping is ok, because if I try to highlight the window when its not showing, I get a message saying it doesn't exist, so I don't think its looking for and finding something else.



    Thanks,

    Tom
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Tom,


    It is quite possible that when the window is hidden, the other object does not exist either.

    So, at the moment, I tend to think that Robert is right about the mapping settings.


    Could you please check whether the needed object is properly highlighted when it is visible on the screen?


    Let us know your results.

  • Hi Alex,



    Yes when the needed object is visible TestComplete can properly highlight it.  So when its not visible and I try to highlight I get the error saying "Unable to highlight this object on screen because it is not visible."  So based on these two findings, the method should work.



    Thanks,

    Tom
  • I've come across this same issue.  And have most recently had a problem with "not Exists".

    Where I have a set of steps if an object exists and a different set of steps if it does not.  Instead my test just stops when the object does not exist, with an object not found error.
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Deborah,


    Perhaps, the problem occurs because some parent object of the checked object does not exist. Look at the error message in the test log, in the Additional Information panel. It should say which object was not found. Make sure that the object is on the screen and check the object's mapping settings. Perhaps, they need to be corrected. You can click the "More Info" link in the Additional Information panel to learn more about the error you faced.


    Instead my test just stops when the object does not exist


    When TestComplete fails to find an object, it posts an error message to the test log. Most likely, you have the Stop on error property enabled in your project. In this case, TestComplete stops the test when an error message is logged. If you don't want your test to stop, disable the property. To do this, right-click your project in the Project Explorer and select Edit | Properties from the context menu. This will invoke the project editor and activate its Properties page. Select Playback from the tree on the left of the page. The setting will be on the right.


     

    • jferreira's avatar
      jferreira
      Occasional Contributor

      I'm having the same kind of trouble with this "If Object Exists" test action on keyword tests too.

       

      During testing, depending on certain previous conditions, I may or may not get a windows message asking if you want to proceed. If the message pops up, I want to click yes and proceed with the test; if the message doesn't pop up, I just proceed as expected.

      So, I put up a "If Object Exists" check for the message box...

      It's working fine when the message box pops up, but if it doesn't show up, the test just stops and logs a "The test execution was interrupted." message.

      On the Additional Info tab I get the following message:

      "Possible reasons:

       - An error or warning occurred during the test run. See the preceding log entries to locate and identify the error.
       - The test run was stopped manually.
       - The test run was terminated as a result of the Runner.Halt method call. "
       
      I don't want to disable the stop on error option. The whole point of using the "If Object Exists" check is precisely to avoid getting a unexpected object error.
       
       Any ideas on what I may be missing?
      Thanks.
      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        As per response from AlexeyK above, are you sure you mapped the top level item of the message box popup?

         

        Because if you haven't it will fail due to stop on error if the parent of the message box is missing.

         

        Whats the error you're getting? You told us what happens, but you didn't say what the actual error message said or where it pointed to?