Win Element Exists
Win Element Exists
Section titled “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.
How it works
Section titled “How it works”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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The element to check. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDesktopSession | — | Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window. |
timeout | number | 0 | Maximum ms to wait for it to appear. 0 = immediate check. |
Output
Section titled “Output”Returns a boolean: true if the element was found within the time; false if not.
Common errors
Section titled “Common errors”| Message | Cause 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.
Example
Section titled “Example”Close a notice dialog only if it appears:
Win Element Exists selector = (dialog "Notice") timeout = 2000 → output: hasNoticeIf condition = hasNotice └─ then: Win Click selector = (button "OK")Related activities
Section titled “Related activities”- Win Wait For — wait for (and require) a state.
- Win Get Attribute — query other properties.