Is it possible to use JS Injection to run code that click on a passed in selector/xpath target ?
Not looking for a click trigger of JS. Looking to see if a workflow has a specific web page up, attaches to it, and it JS Injects code which simulates a mouse click on a provided target.
Is this possible ?
If so, provide sample simple JS code example ?
This looks possible with the below JS method
Ref - Document.querySelector() - Web APIs | MDN
Hope this helps
I found a way to do it. I’ll share my draft working JS shortly. Way from my computer currently.
This is a hard coded example:
function clickOnElement(element, arg1)
// As such, if multiple values are required, JS would need to take arg1 and split
// it on some separation character to get the other values.
// Difference is that is a SIMULATED click and this needed a PHYSICAL click ... which .click() by itself does
// arg1 = Target string to click on
//var targetString = arg1;
var mgPlusElementToClick = document.querySelector("#orderlineAdUnitGrid\\.dataGridView > div > div.slickGridHolder.slickgrid_341831.ui-widget > div.slick-viewport > div > div:nth-child(11) > div.slick-cell.l1.r1 > span.toggle-10.makegood.expand.fa.fa-plus-square-o")
Note that using the Chrome Developer Tools console will save your sanity. Especially in figuring out what selectors should look like:
… like that double backslash within #orderlineAdUnitGrid\\.dataGridView.
Looking at other forums on finding a list of “targets” using querySelector can likely be used to either loop within injected JS and clicking on them or passing up a CSV of targets and having UiPath loop and click on them.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.