web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / "If window contains" r...
Power Automate
Answered

"If window contains" returns false; Selector "Test" returns true

(0) ShareShare
ReportReport
Posted on by 40

Having some trouble with a seeming mismatch in behavior between "If window contains" on a given UI selector and the "Test" button under a that selector. I have a loop that monitors for that UI selector to appear, and on each run the "If window contains" condition doesn't run, yet whenever I stop the flow and run "Test" on that UI selector, the correct element gets highlighted and Power Automate confirms that the selector was found on the page. Has anyone run into a similar issue?

In this instance I am using selectors for application windows, not web, and I am trying to define selectors for and SAP dialog window.

 

 

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Based on the previous topic, it seems like the state of the window can actually be cached and as such, it would likely not work well in a loop. See this topic for reference: https://powerusers.microsoft.com/t5/Power-Automate-Desktop/If-window-contains-not-refreshing-through-flow/m-p/2320493

     

    Instead, I would suggest using Wait for window content to make it wait. You can make it time out after some period of time, but still continue without throwing an error via the On error options of the action. Then use If window contains to check if it has actually appeared after the wait. This would be a better approach than using a loop, and likely unaffected by the bug in caching the window state.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Jared.Leonard Profile Picture
    40 on at

    Huh, that cacheing seems like a major issue for UI Automation, I hope they iron that out soon. I couldn't implement my logic exactly the way you said, because I have two separate windows/selectors I am waiting on, but the Wait for window content step does seem to pick up on the selector properly, even if it takes a few loop iterations to update. I implemented it like this in case it helps anyone who stumbles upon this:

    JLeonard_0-1695649247897.png

     

    Where the On block error is set to "Go to end of block".

     

    Thanks for your reply!

  • Jared.Leonard Profile Picture
    40 on at

    On second inspection, I've tried the described logic on a flow that's been running for about 18 minutes and the caching seems to occur with Wait for window content too, despite it picking up the selector fairly quickly on a separate run. Is there a way to manually invalidate the cache or force a refresh?

  • Jared.Leonard Profile Picture
    40 on at

    Never mind, switched the hanging Wait to target a button within the window being waited on, works like a charm!

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Thank you for sharing your findings. Great stuff. 

    I do agree this is a major issue and hope MS resolves it. For now at least we are aware of it and have some workarounds available.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 335 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard