Forum Discussion

HirendraSingh's avatar
HirendraSingh
Contributor
21 days ago
Solved

how to capture loading which appears for 2,3 seconds

I want to capture loading icon which only appears for 2,3 seconds but not able to highlight it with Object browser as its disappears too fast. So any suggestions how to capture that element.?

This is the loading.

 

  • I had also done some analysis and found this is the easiest way, so marking as solution.

3 Replies

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

    For transient elements, rely on runtime identification, polling, and property checks, with image-based detection as a fallback. Avoid using the Object Repository for elements that appear briefly. In TestComplete, the recommended approach is runtime/dynamic detection combined with polling. This works for both web and desktop applications.

    1. Runtime / Dynamic Recognition

    • Use FindChild or FindAllChildren on the parent window or page.
    • Match the element by properties like id, className, WndClass, or other unique identifiers.
    • This works because short-lived elements may not exist when the test starts.

    2. Polling / Frequent Checks

    • Loop with short delays (100–200 ms) to repeatedly check for the element during its brief appearance.
    • Ensures detection even if it’s visible only for a few seconds.

    3. Property-Based Waiting

    • Use WaitProperty("Visible", true, timeout) or WaitProperty("Exists", true, timeout) once you locate the element.
    • Synchronizes your test with UI changes.

    4. Image-Based Recognition (Fallback)

    • If the element is hard to access in the DOM or control tree, capture it visually using Picture, FindBitmap, or PictureCheckPoint.
    • Works for web and desktop apps alike.

    Web-Specific Example (JavaScript)

    function CaptureLoadingIcon() {
        var parent = Sys.Browser("*").Page("*"); // Web page object
        var found = false;
    
        for (var i = 0; i < 30; i++) { // check every 100ms for ~3 seconds
            var icon = parent.FindChild("className", "loading-icon", 0); // replace with actual property
            if (icon != null && icon.Visible) {
                Log.Message("Loading icon appeared");
                found = true;
                break;
            }
            Delay(100);
        }
    
        if (!found) {
            Log.Message("Loading icon did not appear");
        }
    }
    

    Note: This snippet is web-specific, but the same approach applies to desktop applications. Replace the parent object with the main window or panel containing the loading icon, and adjust the property used in FindChild accordingly.

    🤖 AI-assisted response
    👍 Found it helpful? Click Like
    ✅ Issue resolved? Click Mark as Solution