Closed kensoh closed 3 years ago
You can override the UI by setting msg.script So before the tagui node you could simply add a "file in" node that reads a file and save the result to msg.script or you chould add a HTTP request node, to download the script and save that to msg.script Basically giving the same result Replicating your csv file example would be a little more complex. We can use the the csv node to parse a file (local or dowloaded using http request node, or while testing uploading in browser using the inject file node. That will then send a message per line, where msg.payload contains the data, and we can then pass that as variables to tagui using the "Param" switch
Don't get me wrong, its a few lines of code to update the node to allow for parsing URL and a csv file. I just believe forcing the user to use NodeRED nodes opens the users eyes for a much stronger and versatile alternative ?
Hi Allan, thanks! What you suggested makes sense to me. I can point users to this issue if they ask. 2 comments -
After trying for some time I couldn't figure out how to save result to msg.script from an input file, couldn't find usable results from googling (not impt, I think a Node-RED user will know). But from what you describe I think this is a better approach to doing it the Node-RED way.
For CSV file, from what you describe, the solution will be simpler. If it is a URL, can be retrieved to stored locally using http request node. Once there is a local csv file, it can be passed through TagUI node as a parameter. TagUI will interpret the parameter ending with .csv as a signal that this is the datatable to consume for the batch automation.
copying @Jelleebeen
1) I'm going to assume we are talking a nodered running on a users computer. Then simply use the "file in" node. Some thing like this should do it.
[
{
"id": "c54841d2.29a1",
"type": "file in",
"z": "1d07f154.be2ecf",
"name": "",
"filename": "/tmp/findme.tag",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"x": 340,
"y": 640,
"wires": [
[
"4750fe25.403bb"
]
]
},
{
"id": "8355642e.6b8028",
"type": "inject",
"z": "1d07f154.be2ecf",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 170,
"y": 640,
"wires": [
[
"c54841d2.29a1"
]
]
},
{
"id": "4750fe25.403bb",
"type": "function",
"z": "1d07f154.be2ecf",
"name": "",
"func": "msg.script = msg.payload;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [
{
"var": "puppeteer",
"module": "puppeteer"
}
],
"x": 200,
"y": 700,
"wires": [
[
"4178f306.d4117c"
]
]
},
{
"id": "4178f306.d4117c",
"type": "tagui tagui",
"z": "1d07f154.be2ecf",
"name": "",
"headless": false,
"nobrowser": false,
"param": true,
"quiet": true,
"script": "https://www.google.dk/imghp?hl=en&ogbl\ntype q as cute kitten[enter]\nwait 2 sec\nif present('//div[@data-ri=\"0\"]')\n snap //div[@data-ri=\"0\"] to kitten.png\nelse if present('//table//img')\n snap //table//img to kitten.png",
"x": 350,
"y": 700,
"wires": [
[],
[],
[]
]
}
]
Thanks Allan! I've tried for some time but wasn't able to run it. Below is a simple trigger using timestamp vs using a file.
findme.tag
echo xyz
https://ca.yahoo.com
node-red
[{"id":"65b0479b.54213","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"c54841d2.29a1","type":"file in","z":"65b0479b.54213","name":"","filename":"/tmp/findme.tag","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":320,"y":220,"wires":[["4750fe25.403bb"]]},{"id":"8355642e.6b8028","type":"inject","z":"65b0479b.54213","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":220,"wires":[["c54841d2.29a1"]]},{"id":"4750fe25.403bb","type":"function","z":"65b0479b.54213","name":"","func":"msg.script = msg.payload;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":300,"wires":[["4178f306.d4117c"]]},{"id":"4178f306.d4117c","type":"tagui tagui","z":"65b0479b.54213","name":"","headless":false,"nobrowser":true,"param":true,"quiet":true,"script":"echo abc","x":350,"y":300,"wires":[[],[],[]]},{"id":"7dd22cb.07c64d4","type":"tagui tagui","z":"65b0479b.54213","name":"","headless":false,"nobrowser":false,"param":true,"quiet":true,"script":"echo abc","x":330,"y":120,"wires":[[],[],[]]},{"id":"ff05fe8f.5a2b38","type":"inject","z":"65b0479b.54213","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":120,"wires":[["7dd22cb.07c64d4"]]}]
The timestamp flow above works and shows some output. The file flow shows timestamp injected and nothing happens.
Ups, sorry I forgot
return msg;
in the function node
Thank you! Works now. Below updated TagUI workflow file and Node-RED flow.
Behaves as expected - output xyz and visits Yahoo instead of Google in the TagUI node.
findme.tag
echo xyz
https://ca.yahoo.com
function code
msg.script = msg.payload; return msg;
node-red nodes
[
{
"id": "65b0479b.54213",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "c54841d2.29a1",
"type": "file in",
"z": "65b0479b.54213",
"name": "",
"filename": "/tmp/findme.tag",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"x": 320,
"y": 260,
"wires": [
[
"4750fe25.403bb"
]
]
},
{
"id": "8355642e.6b8028",
"type": "inject",
"z": "65b0479b.54213",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 260,
"wires": [
[
"c54841d2.29a1"
]
]
},
{
"id": "4750fe25.403bb",
"type": "function",
"z": "65b0479b.54213",
"name": "",
"func": "msg.script = msg.payload; return msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 180,
"y": 320,
"wires": [
[
"4178f306.d4117c"
]
]
},
{
"id": "4178f306.d4117c",
"type": "tagui tagui",
"z": "65b0479b.54213",
"name": "",
"headless": false,
"nobrowser": false,
"param": true,
"quiet": true,
"script": "echo abc\nhttps://www.google.com",
"x": 330,
"y": 320,
"wires": [
[],
[],
[]
]
}
]
Hi @skadefro, I had a call with @Jelleebeen (Dave Hurst) whom previously created a PR for RabbitMQ in OpenFlow and will be working on iterating C# version of TagUI (am organising a meeting with him and Nived and sync with you). He suggested an idea on Node-RED that I thought would be interesting for you to consider.
Right now the usage is click into the TagUI node to paste or type the script there. What if there is an option to take that as an input (from a file, or URL for example). This opens up the use case of decoupling the Node-RED flow from the TagUI flow. And the same flow can be running different RPA scenarios by changing the input. (TagUI can take URL as an input for workflow file parameter).
Also as a side note, TagUI has the concept of datatables (https://tagui.readthedocs.io/en/latest/advanced.html#datatables) to do batch automation base on different data. At some point in time, this might be raised by users, so I didn't raise this yet. Let users' actual demand drive feature requests for consideration.