Cypress get Function with two class names

Viewed 4773

I have a button on my website with two classes:

<button class="btn_primary btn_inventory">ADD TO CART</button>

I want to click this button with this code:

 cy.get('btn_primary btn_inventory').click();
1 Answers

You can't directly use the class name as you have used here. you need to use CSS selectors. in your case, it should be corrected as,

cy.get('.btn_primary.btn_inventory').click();

Refer this to learn more about css selectors CSS Selectors W3Schools

Related