Hey guys I need help with Inject js activity, I just receive a message error when the activity is executed.
I got this error HRESULT 0x80020101, I already did a research and most of cases occurs when you have a syntax error in the javascript, but the script works perfectly in my page.
I’d appreciate any help in identifying the problem.
this is the script
function () {
var table = document.getElementById('"+tableId+"');
var rows = table.childNodes[0].childNodes[0].childNodes.length;
var field = table.childNodes[0].childNodes[0].childNodes;
var array = [];
for(var i =0; i <= rows - 1; i++){
array[i] = New Array(field[i].childNodes[1].innerText, field[i].childNodes[3].innerText,
field[i].childNodes[4].innerText);
}
return array;
}
Thank you for answer, and yes Kannan, the tableId is a variable, I just found the reason, it was actually a Syntax error, the word New must be lower case… also the word For and Return; when I copied and pasted my code into uipath, the words changed to CamelCase, so take care. But the code still does not work. the return is not returning nothing at all and I don’t know why.
[Update]
I couldn’t return the variable array and I don’t have enough time to find out the reason, so I just change the way to return my variable, this is what i did:
`function () {
var table = document.getElementById('"+tableId+"');
var rows = table.childNodes[0].childNodes[0].childNodes.length;
var field = table.childNodes[0].childNodes[0].childNodes;
var array = """";
for(var i =0; i <= rows - 1; i++){
array += field[i].childNodes[1].innerText +"",""+ field[i].childNodes[3].innerText +"",""+
field[i].childNodes[4].innerText + "";"";
}
return array;
}`
I changed the array to string variable and added a separator “;”, so this way I can use something like split or subString method.
I use this piece of code to get info from a table of divs, I mean, I can’t use Data Scraping because the table what I want to scrap is not a table is something like a “table of divs”, I get the principal ID var table, then the next divs what is supposed to be the rows rows and finally the fields var field.
I iterated through the var rows and got the info what I want field[i].childNodes[1].innerText