Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  74] [ 3]  / answers: 1 / hits: 33874  / 5 Years ago, thu, september 5, 2019, 12:00:00

I am trying to select two buttons one after one , a Delete button and after that the Yes popup confirmation ,by this:



cy.get('.btn-danger').last().click();
cy.get('.btn-primary').click();


But i got this error:



CypressError: cy.click() can only be called on a single element.
Your subject contained 2 elements.
Pass { multiple: true } if you want to serially click each element.


More From » cypress

 Answers
10

I think there are two buttons with btn-primary class in your popup DOM (yes and cancel?). Try to access the yes confirmation button by its id or something. Or if you're sure about the order, then use .first() or .last() like you used for clicking the delete button.


[#51689] Thursday, August 29, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
domeniccolti

Total Points: 276
Total Questions: 98
Total Answers: 93

Location: India
Member since Fri, May 13, 2022
2 Years ago
domeniccolti questions
Mon, Oct 18, 21, 00:00, 3 Years ago
Thu, Oct 14, 21, 00:00, 3 Years ago
Thu, Jul 15, 21, 00:00, 3 Years ago
Sat, Oct 24, 20, 00:00, 4 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
;