# Element.exists

Check whether this reference is still valid, or query its descendants.

```js
element.exists(selector?)
```

## Arguments

| Argument | Type | Meaning |
| --- | --- | --- |
| `selector` | object \| string | Optional descendant selector. Omit to check this reference. |

## Returns

Boolean; stale self references return false, other errors throw.

## Example

```js
const element = UIHelper.waitForElement({id: "target", visible: true, enabled: true}, 5000);
console.log(element.exists());
```

## Notes

With a descendant selector, a stale parent is an error. Without arguments, a stale self reference returns false; other failures throw.

[All JavaScript APIs](https://mcp.applesauceos.com/doc/api.md) · [Automation playbook](https://mcp.applesauceos.com/doc/ai.md)
