When cypress clicks the button it seems the click does not have any effect, because clicking manually on the button I see a message confirmation.
This is the HTML code from the button:
the Step definition file:
When("I click Save button",() =>{
backofficeCreateDeleteClerkPage.saveBtn().click({froce:true})
})
and the js for the button
saveBtn() {
return cy.get('im-page.hydrated').shadow().find('im-button.hydrated').contains('Save')
}
Any help is appreciated.
You can directly use the button text Save and use contains for this:
cy.get('im-page.hydrated', {includeShadowDom: true})
.find('im-button', {includeShadowDom: true})
.eq(2)
.find('button', {includeShadowDom: true})
.click({force: true})
In case you dont want to add {includeShadowDom: true} in your code or repeat it, you can just write it once in your cypress.json and then by default commands like get, find etc will traverse shadow DOM's.
Is "force" misspelled here?
backofficeCreateDeleteClerkPage.saveBtn().click({froce:true})
You've got multiple shadows. You should be able to find it like this.
cy.find('im-button.hydrated')
.shadow()
.contains('Save')