I am trying to access a nested webelement using webdriverio framework.
I have the following code
function selectSales(sfilters, salesflowName) {
const sflow = $$("app-filters-manager app-salesflow-panel mat-expansion-panel").find(element => {
return element.getText() === salesflowName;
});
/* The below is to select the checkbox from a list of checkboxes under
the parent */
sfilters.forEach(fil => {
sflow.$$("mat-list-option").find(el => { //* > This is where I am getting error.
return el.getText().includes(fil);
}).$('mat-pseudo-checkbox').click();
});
}
I am getting Cannot read property '$$' of undefined
Not sure why the error shows up. 'sflow'
is the parent webelement and accessing the child elements using $$("mat-list-option")
is where the error appears.
It looks that your selector is not valid. Shouldn't it be like this (selector for looking for class)?
const sflow = $$(".app-filters-manager .app-salesflow-panel .mat-expansion-panel").find(element => {
return element.getText() === salesflowName;`
Same in other selectors. And find should return one children, so it is OK.
But if it is valid, are you sure, that elements are in DOM?