Reputation: 13
Query URL - "XYZ "
From the above URL we can see different category's like a, b & c.
Now, my question is how we can get the length present in each category and display in the output?
For example c has 13 count listed, This I want to show case using cypress code.
Upvotes: 1
Views: 201
Reputation: 18624
You can iterate over the tab sections using each()
, perform a click, and then calculate the length of all the questions. A simple program demonstrating that -
it('Print the Number of Questions in each Tab', function() {
cy.visit('https://www.kreditbee.in/faq')
cy.get('button[role="tab"]').each(($ele) => {
cy.wrap($ele).click()
cy.get('svg').its('length').then((len) => {
cy.log('The number of questions in ' + $ele.text() + ' tab: ' + len)
})
})
})
Upvotes: 1