Cypress - how to find by text content?

后端 未结 3 1831
面向向阳花
面向向阳花 2021-02-12 17:40

In Cypress, I want to select a button from a group of buttons based on its text-content. How can I do it? Here is my approach:

export const getCustomerButton = (         


        
3条回答
  •  后悔当初
    2021-02-12 18:28

    This will yield the DOM element with YOUR_BUTTON_CLASS which contains text 'Customer'. Is that what you're looking for?

    cy.get('YOUR_BUTTON_CLASS').contains('Customer');
    

    Here the documentation for .contains cypress command.

提交回复
热议问题