I have a HTML code like this
<ul class="menu-main-nav-container">
<li>Home</li>
<li>About</li>
<ul>
<li>About1</li>
<li>About2</li>
<li>About3</li>
</ul>
<li>Contact</li>
<li>Links</li>
</ul>
What i want to achieve is to get all the text of li's and convert it to array so that i can use each array for comparison to other values. but the twist is the li's are constantly changing
So far i have this code on cypress
it('List to array', () => {
cy.get('*[class^="menu-main-nav-container"]').eq(0).then($text => {
const text = $text.text().toString().slice('')
cy.log(text[0])
})
})
It just log the text 'H' for now but i want to achieve is text = ["Home", "About", "Contact", Links" ] so that i can compose text[0] that i can use
I'm so stuck right now