Reputation: 125
I've got an HTML code like:
<div class='textDiv'>
<h1>Header 1</h1>
<h2>Header 2.1</h2>
<p>Paragraph</p>
<h2>Header 2.2</h2>
<h2>Header 2.3</h2>
</div>
Then on Cypress I've got a code like:
cy.get('textDiv').find('h2').then($h2 => {
cy.log($h2[2]);
});
Trying to get "Header 2.3", but getting "h2" instead.
Is it possible to get the value "Header 2.3"?
Upvotes: 1
Views: 2305
Reputation: 78
Does this get the value you are looking for?
cy.get('textDiv').find('h2').then($h2 => {
cy.log($h2[2].innerText);
});
Upvotes: 2