Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

67
Views
Get text of multiple elements in Nightwatch.js and compare it with a list of strings

I'm a beginner in software automation testing. First I learned Selenium with python, so I know there's a possibility to get the inner text of multiple elements, which is given back in a list. Now I'm working with nightwatch.js and I want to get the text of all headings in the top line of my website - maybe store them in list - and compare these strings with expected strings in a prepared list. I've just reached the point where I get the text of the headings. I wanted to store them in a list (with list.push) and assert both lists (by 'is in' or 'contains'), but this does'nt work. Does anyone know advice for this problem?

browser.elements('css selector', ".p-menuitem-text.ng-star-inserted", elements => {
                let list = ['AGB', 'Datenschutz', 'Impressum'];
                elements.value.forEach(element => {
                   console.log(Object.keys(element)[0]);
                   let key = Object.keys(element)[0];
                   let id= element[key];
                    
                    
                  browser.elementIdText(key, function(result){
                        let i = result.value;
                        console.log(i);                       
                        })                                   
                })
                console.log(list)
            })          

This is my current output:

Thanks for help.

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs