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.
function clickOnElement(element, arg1)
{
// NOTE: UiPath JS Inject gives a SINGLE input argument for using Javascript Inject.
// 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.
// This was developed from: https://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript
// Difference is that is a SIMULATED click and this needed a PHYSICAL click ... which .click() by itself does
// Inputs:
// 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")
mgPlusElementToClick.click();
return("Clicked !!!");
}
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.