I need to check the checkbox based on the text in HTML
and I have the solution with Javascript but in UiPath is not working when I add “Inject Js Script” Edit fiddle - JSFiddle - Code Playground
function ExecuteScript() function checkBoxFromLabelText(str) {
const labels = [...document.querySelectorAll('label')];
const label = labels.find(label => label.textContent.trim() === str);
if (label) label.querySelector('[type="checkbox"]').checked = true;
}
checkBoxFromLabelText('Text 1');
I was trying this method and his not working:
"function ExecuteScript() { function checkBoxFromLabelText(str) { " +
" const labels = [...document.querySelectorAll('label')]; " +
" const label = labels.find(label => label.textContent.trim() === str); " +
" if (label) label.querySelector('[type=""checkbox""]').checked = true; " +
"} " +
"checkBoxFromLabelText('Text 1');} "