Cypress实现拖拽
使用Cypress内置的trigger方法实现拖拽一个元素到另一个同类型元素,实现排序
Typescript实现方法:
export function dragAndDrop(sourceLocator: string, targetLocator: string) {
const dataTranferMock = { setData: () => {}, setDragImage: () => {} }
cy.get(sourceLocator)
.trigger('pointerdown', { button: 0 })
.trigger('dragstart',{dataTransfer: dataTranferMock});
cy.get(targetLocator)
.trigger('dragover')
.trigger('drop');
}