Cypress.Commands.add('clearScheduleEditor', () => {
cy.get(getBySelector("schedule-editor")).find(".fc-event").should(() => {
}).then($events => {
if ($events.length) {
Cypress._.each($events, (event) => {
console.log(event)
})
}
})
})
Here i have my code sample where im trying to delete all ever existed events. Thats why i need to .each them to open every single one to delete. But the problem is that .each func returns me as a value of callback (event) the Dom element, but i need an cypress element
I need to do reversed operation to this Get native HTML element in Cypress
Need to get Cypress element
2
Answers
You would be needing
Cypress.$()
to wrap the DOM element into a JQuery object, post which you can usecy.wrap()
to convert it into a Cypress object to performclick
or other actions required to delete the event. A sample of the above looks like:To convert a DOM element to a Cypress element, you can use
cy.wrap()
to wrap the DOM element, thereby converting it to a Cypress object.