Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
How to return getTexts for array of elements with isExisiting

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)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!