MQTT General

10 action groups: ManagerAction, MouseAction, KeyboardAction, BrowserControl, ElementAction, ImageAction, OthersAction, EmailAction, DeveloperAction, General Debug

Element → count_element

AI-generated

Summary

Count the number of elements matching a specified selector on a webpage via MQTT by publishing a payload with selection details to a defined topic and optionally waiting for a response.

Inputs

  • Topic (required) — The MQTT topic on which to publish the count element request message.
  • QoS — Quality of Service level for MQTT message delivery (0, 1, or 2).
  • Include Input Items — Optionally include selected fields from the workflow input items in the payload under payload.inputItems.
  • Include Input Items Fields — Specify which fields from the input items to include if 'Include Input Items' is enabled.
  • Wait For Response — Whether to wait for and capture a response message on a response topic before returning output.
  • Response Topic (required) — MQTT topic to subscribe to for receiving the response if waiting for a response (default is 'RES_' prepended to the Topic).
  • Response Timeout (ms) — Maximum time in milliseconds to wait for a response message when 'Wait For Response' is enabled.
  • Parse Response As JSON — Whether to parse the received response payload as JSON.
  • Target — High-level selector string (e.g., 'css=button', 'id=demoInput') to locate the elements to count.
  • XPath — Explicit XPath selector string to locate the elements to count when not using the 'target' selector.

Output shape

a list with one item whose JSON contains the original input data enriched with an 'mqtt' object holding the topic, action details, payload inputs (including the target or xpath), and optionally a response object if 'Wait For Response' is enabled and a response is received.

If 'Wait For Response' is true, the node subscribes to the specified Response Topic and waits up to the configured timeout for a reply, parsing it as JSON if requested. Errors are thrown if required parameters are missing, or if publish or response times out, unless the workflow's 'Continue On Fail' is set to true, in which case error details are returned in the output.

Examples

Example 1: Count all buttons on the page.

Set Topic to 'page/actions', QoS to 1, Target to 'css=button', and Wait For Response to false.

Example 2: Count all input fields with id 'email' and wait for response on topic 'RES_page/actions'.

Set Topic to 'page/actions', Target to 'id=email', Wait For Response to true, Response Topic to 'RES_page/actions', Response Timeout to 10000 ms, and Parse Response As JSON to true.

Links

Discussion