Onclick (event)

What I am attempting to do is, activate a button on an external website page. The first question I want to ask is, is this even possible using Node Red? If it's not, so be it.

But assuming it is possible, then is the approach to;

  • Use a POST http request, into a function node,
  • where the function node contains code to locate the 'webpage-button' on the website;
  • the code using the Button ID, perhaps "getElementById" or something like that?

The page inspection reveals the Button as;
<button id="export_data" onclick="exportPOINTS("markers")">Download Field Markers

Any guidance is greatly appreciated

Node-RED cannot do it itself because it runs on YOUR server. The external website runs in YOUR browser. Obviously, browser security is quite important so you are restricted by what you can do - at least without using a browser extension since they have more access to the browser internals (which is why you shouldn't install random browser extensions).

You could certainly trigger a button using a command written in your browser's devtools console, but that isn't really automatable from Node-RED.

Having said that, you could make use of a library such as Puppet which provides a headless "browser" that you CAN control. There is at least one Puppet node in the library. Using Puppet or similar, that allows you to have a full headless environment that will run JavaScript, then you can certainly use that to click a button on the page.

1 Like

Thanks, that certainly does perform the button-click I need.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.