Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I remove a HTML element using Cypress?

Is it possible to use Cypress to find and delete an element from the HTML? And how to do it?

Edit: This works:

cy.get(selector).then((elem) => {
  const elemHtml = elem.get(0)
  elemHtml.remove()
})
like image 807
Marcos Daniel Morais Avatar asked May 24 '26 14:05

Marcos Daniel Morais


1 Answers

Variation on @krema's answer:

cy.get(selector).invoke('remove');
like image 155
webdevguy Avatar answered May 26 '26 04:05

webdevguy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!