Can anyone help me to know how we can take count of urls present in sitemap. Thanks in advance
Can anyone help me to know how we can take count of urls present in sitemap. Thanks in advance
Use jQuery to count the urls
cy.request('sitemap.xml')
.its('body')
.then(xml => {
const count = Cypress.$(xml).find('url').length;
cy.log(count)
})
Assuming all your url’s have a tags, and you have to assert the count you can do like this:
cy.get('a').should('have.length', 10)
If you just want to print the length you can like this:
cy.get('a')
.its('length')
.then((len) => {
cy.log(len) //prints length
})