Solved
Forum Discussion
3 Replies
- rraghvani
Champion Level 3
Is it web or desktop application?
- Hassan_Ballan
Champion 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