Skip to content Skip to sidebar Skip to footer

Javascript Selector: Find Checkbox For Corresponding Sibling Text

We are doing Test Automation. We need to locate elements under kendo-grid-columnlist, and given a Text Input (Product Type) in Span, locate its corresponding Input Checkbox. So if

Solution 1:

You can do the following,

let spans = document.querySelectorAll('kendo-grid-columnlist .k-checkbox-label');
let myElement = null;
spans.forEach(item => {
        if(item.innerText === 'Product Type') {
            myElement = item.parentNode.firstElementChild;
        }
});
console.log(myElement);

Post a Comment for "Javascript Selector: Find Checkbox For Corresponding Sibling Text"