Reputation: 707
I am running with Chrome 74 and am wanting to write a test that will 'spam' click a counter.
Is there any way to write it so it will click x
times instead of writing this over and over:
cy.get('[data-cy=click-up]').click()
I asked in the Cypress Gitter and someone had responded with:
Providing that your selector matches n+ Dom elements, its going to click all of em
cy.get(selector).click({multiple: true})
But this does not work in my problem.
If I could I'd share direct code but I am under an NDA.
So, I took jon's comment and yes a for loop works to re-create that 'spam' click.
Example:
describe('increase the counter', () => {
it('spam click by 10', () => {
for(let n = 0; n < 10; n ++){
cy.get('[data-cy=click-up]').click()
}
})
})
Upvotes: 0
Views: 1304
Reputation: 707
So, I took jon's comment and yes a for loop works to re-create that 'spam' click.
Example:
describe('increase the counter', () => {
it('spam click by 10', () => {
for(let n = 0; n < 10; n ++){
cy.get('[data-cy=click-up]').click()
}
})
})
Upvotes: 2