Skip to content

SAP — Element exists

Type: sap-element-exists  ·  Package: SAP Activities v1.0.5  ·  Output: boolean

Checks whether an element exists on the current SAP screen and returns true or false. It doesn’t fail if the element isn’t there: it just returns false. It is the way to handle what sometimes shows up —an unexpected dialog, a warning, a field that only appears in certain cases— and decide what to do.

It first waits for SAP to finish whatever it is processing (so it doesn’t look at the screen from before the last action) and then looks up the element by its selector once: it doesn’t wait for it to appear and doesn’t use elementTimeout. The result usually feeds an If.

ParameterTypeDefaultDescription
selectorselector—Element to look for. Ex: "wnd[1]" to know whether a modal window is open.
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.

Returns a boolean: true if the element exists on the current screen, false if not.

It doesn’t fail because the element is missing: it returns false then. It only fails if the selector arrives empty ('selector' is required.) or with the errors common to all activities, such as a missing session.

Read and close a dialog only if it appears:

SAP Element Exists selector = "wnd[1]" → output: hasDialog
If condition = hasDialog
└─ then:
SAP Get Text selector = "wnd[1]/titl" → output: dialogTitle
Log message = "Dialog: " + dialogTitle
SAP Close Modal