Reputation: 137
Any help would be appreciated. Thanks
Upvotes: -2
Views: 209
Reputation: 2571
Since this is button appears in a modal, you'll want search within the modal DOM element so you grab the correct one and not another one that exists in the DOM.
We will us the powerful .contains()
with a regex as an argument since adding a selector could make it more brittle.
NOTE: I don't see html for your modal so I will use a dummy selector for it in the example below.
// made up modal selector
cy.get('.modal')
// always good to assert the modal should be visible
.should('be.visible')
.contains(/upload in this folder/i)
// make sure it is visible before clicking
.should('be.visible')
.click()
Upvotes: 0
Reputation: 350
You can select by the text of the button,
cy.contains('Upload in this folder').click()
Upvotes: 3
Reputation: 18650
You can use a combination of selector and inner text with contains
for this.
cy.contains('div', 'Upload in this folder').click()
Upvotes: 0