Forum Discussion

Simmy7's avatar
Simmy7
New Contributor
2 days ago

Windows form not always recognized in property checkpoint

I have added existing tests from one project into a second project. I run a test that includes one of the tests from the 1st project. In this test I first do a WaitAsChild operation witha 90 second timeout and I can see that the form is open in lest than the 90 seconds. Then I run a property checkpoint to check if a form is VisibleOnScreen. Sometimes TestExecute will give an error that it can't find the Aliases.AppName.FormName. Other times it works fine. After a failure if I readd the tests to the 2nd project it works fine. NameMapping is the same in both projects. 

Any suggestions how to prevent this problem?

6 Replies

  • scot1967's avatar
    scot1967
    Icon for Champion Level 2 rankChampion Level 2

    .... When I say the solution did not scale well I should be more specific.  Changing the Name Map in one place affected several projects and we had to keep this in mind as well as project dependencies.

  • scot1967's avatar
    scot1967
    Icon for Champion Level 2 rankChampion Level 2

    Hello Simmy7,

    What properties are you using to identify your object?  The identification of the object itself can cause this type of behavior.

    Name mapping in multiple projects can be difficult to maintain. This does not sound like a name mapping issue but  I will toss this in as it may be useful.  I used this when we were using name maps.  It didn't scale well and had it's own quirks but it resolved the issue of needing to maintain separate name maps for an application.

    Merge Name Mapping Files
    https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/how-to/merge.html

    ... If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 3 rankChampion Level 3

    It sounds like this issue is caused by a timing or synchronization problem, especially since the failure is intermittent and the form does eventually appear. The fact that you increased the WaitAsChild timeout to 90 seconds suggests the form can take a while to become available — and not necessarily consistently.

    Even though WaitAsChild waits for the form, it doesn't guarantee the form is fully ready for interaction. So, it's possible that the checkpoint runs before the form is fully initialized.

    To improve reliability, I suggest the following:

    Add additional property checks before the VisibleOnScreen checkpoint:

    if (Aliases.AppName.FormName.Exists &&
        Aliases.AppName.FormName.Enabled &&
        Aliases.AppName.FormName.VisibleOnScreen) {
        // Proceed with checkpoint
    } else {
        Log.Error("Form is not fully available.");
    }
    

    This way, if the failure happens again, you can pinpoint whether the form didn’t Exist, wasn’t Enabled, or just wasn’t VisibleOnScreen.

    You can also increase the default timeouts for Exists, Enabled, and VisibleOnScreen to ensure these checks have enough time to succeed.

    Lastly, I don't think the issue is specifically due to importing tests from another project — it just coincidentally manifests that way. The root cause is more likely related to when and how the form becomes available during execution.

    🤖 AI-assisted response.
    💬 Found this helpful? Click Like to show appreciation.
    ✅ Issue resolved? Mark as Solution to help others.

  • Simmy7's avatar
    Simmy7
    New Contributor

    I have tried all of that and once I do the locating on screen it works fine. The problem is that it doesn't happen all the time and the problem goes away when I readd the test to the second project.

    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      What version of TestComplete are you using?

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    You will have to use TestComplete to diagnose the issue - ensure your name mappings are correctly defined and that TestComplete can locate the UI object on screen based on your chosen property values. Ensure the child object is actually created, before checking property values - use the Object Browser to verify this.