I am aiming to return a set of texts from a single locator that shares three elements and they are stored in an array of elements name selector (being selector storing three elements)and before it returns texts I want them to pass isExisting() flag but it throws "TypeError: selector.isExisting is not a function" if I remove isExisting part of code then it works fine and return the three text values. My code is:
async function getTreeTexts(browser, sidebar, parentClass, treeClass, spanClass = 'caption') {
//await browser.ideOpenSidebar(sidebar)
var cl = c => c ? '.' + c : '';
var selector = await browser.$$(`${cl(parentClass)} .ace_tree${cl(treeClass)} .tree-row span${cl(spanClass)}`);
await browser.ideOpenSidebar(sidebar)
await selector.isExisting().then(async function (exists) {
if (exists) {
// Depending on the number of matches, items can be a string or an array of strings. Coerce to array.
let configs = [];
for (let element of selector) {
try {
let text = await element.getText();
configs.push(text);
} catch (err) {
configs.push('[deleted]');
}
}
return configs;
} else {
return [];
}
});
}
Can someone please assist me here if I am doing something wrong? (my guess is, isExisiting() not handling all three elements at the same time)