Loop slideshow excluding clone duplicates in Cypress
P粉197639753
P粉197639753 2024-03-25 22:41:02
0
1
369

I am new to Cypress and am trying to cycle through a slideshow excluding cloned duplicates. I'm using .each() for indexing in cypress but that doesn't work. Below is my code

if (index != 0 && index >= 22) {
    //do something
} else {
    //do something
}

Here is a sample snapshot of my html code:

Can anyone come up with the logic to only loop to the original slide?

P粉197639753
P粉197639753

reply all(1)
P粉677684876

You can use :not() Pseudo selector

cy.get('div.swiper-slide:not(.swiper-slide-duplicate)')
  .should('have.length', 23)   // to show loop is filtered, remove once confirmed
  .each($swiperSlide => {
    ...

Or if you prefer to inspect inside the loop, use the .not() method

cy.get('div.swiper-slide')
  .each($swiperSlide => {
    if ($swiperSlide.not(".swiper-slide-duplicate").length) {

    } else {

    }
  })
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!