Skip to content

Win Element Exists

Type: win-element-exists  ·  Package: Desktop Activities v1.0.8  ·  Output: boolean

Checks whether an element exists in the application and returns true or false. It does not fail when the element isn’t there: it simply returns false. It’s the way to handle interfaces that sometimes show something —an error dialog, a message, a conditional button.

It searches for the element by its selector. By default (timeout = 0) it makes an immediate check, without using the project’s timeout. With a larger timeout, it retries every 250 ms until then before returning false. The result usually feeds an If.

  • Only visible windows are searched; inside them, what counts is that the control can be located (it doesn’t check whether it is scrolled out of view).
  • Any problem while searching (an ambiguous selector, a window closing mid-query) counts as “doesn’t exist”.
  • It does not interact with the application or bring it to the front.
ParameterTypeDefaultDescription
selectorselector—The element to check.
ParameterTypeDefaultDescription
sessionZoanDesktopSession—Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window.
timeoutnumber0Maximum ms to wait for it to appear. 0 = immediate check.

Returns a boolean: true if the element was found within the time; false if not.

MessageCause and fix
'selector' is required.The selector is missing or invalid. Capture it with UI Discover.

Apart from that, the activity does not fail: a selector with no window node and no session simply returns false, so check the selector if you always get false.

Close a notice dialog only if it appears:

Win Element Exists selector = (dialog "Notice") timeout = 2000 → output: hasNotice
If condition = hasNotice
└─ then:
Win Click selector = (button "OK")