angular - 如何使用 cypress 在 Angular 应用程序中拖放元素?
问题描述
我想从列表中拖放元素以使用移动图标对其重新排序。
所以,我添加了 3 个项目,并尝试了这个功能:array-form.po.ts:
export const dragdropItem = (dragedElSelector) => {
const dataTransfer = new DataTransfer();
if(dragedElSelector == null){
console.log(dragedElSelector)
}
cy.get(dragedElSelector).then(($form) => {
const coordsDrag = $form[0].getBoundingClientRect();
cy.wrap($form)
.trigger('dragstart', {
clientX: coordsDrag.left,
clientY: coordsDrag.top,
which: 1,
dataTransfer
})
.trigger('mousemove', {
dataTransfer
});
cy.get(dragedElSelector).trigger('drop', {
dataTransfer
});
});
};
数组-form.spec.ts :
it('should add item and reorder the list of arrayForm with dragdrop', () => {
getAddItemButton().click();
getArrayFormRows().should('have.length', 3);
getCollapsedButton().eq(2).click();
getArrayFormTextFieldThird().type('3');
getPassengerComboBox().should('be.visible');
getPassengerComboBoxThird().click({force:true});
getPassengerComboBoxValueThird().click({force:true});
getPassengerComboBoxThird().should('contain', 'Gauss Capital');
getPassengerComboBoxThird().click({force:true});
cy.wait(2000);
dragdropItem(
getMoveIcon().eq(0)
);
cy.wait(1000);
});
但我收到了这个错误:
$form[0].getBoundingClientRect is not a function
谁能帮帮我。
解决方案
推荐阅读
- php - 将 id 传递给 URL 时如何发布 the_content
- javascript - JavaScript 中的对象字面量问题
- c# - MVC 控制器中的 List____() 应该对用户返回什么未经授权?
- database - 为什么 XY 不是候选键?
- baseline - OSquery - 如何预加载数据以查找受感染的文件
- android - 检测位置设置何时可用(例如:记录其使用时间等)?
- vue.js - 在 vue.js 中添加插件失败
- javascript - 尝试制作动态填充的链接选择框以在页面上显示特定图像
- ubuntu - 程序图标在任务栏上显示两次。它不是双重安装的。我怎么能只有一个?
- ios - 如何在 iOS 之外使用/解码快速编码的 base64 字符串?