I have a list of elements with the following numbers - actually it's a date picker:
[26,27,28,29,30,31,1,2,3,4,5,6,7,8,9,10,........27,28,29,30,31,1,2,3,4] //days of month
I need to select two dates like 6 and 27 as a date range. The problem is, there are duplicated numbers in the list and when the iteration starts, the first 27 selected, not the second one. It ruins my test because first date 27th is from previous month. Current month starts @ 1, so I need to select the date after 1.
//Current behavior: My test clicks on 6 and in the new iteration, clicks on the first 27.
I need to do the iteration to check the numbers and skip the first occurrence and click on the second one.
How I can solve this issue with each? I tried like this, but eq() doesn't work.
let dayVar = 27
.find('.datepicker-row > a').children('span').each(($el, index, list) => {
if($el.text() > 25 && index < 10) {
cy.wrap($el).should('contain.text', dayVar).eq(1).click()
} else {
cy.wrap($el).should('contain.text', dayVar).eq(0).click()
}
})
Many thanks!