使用Cypress.io无法拖放元素

时间:2019-02-07 00:48:29

标签: drag-and-drop cypress

我正在将一个文本元素从树中拖动到放置区域。在元素下垂后将显示一个表格。未显示任何错误,但元素并未被删除。 同样,当我们手动拖动时->我们会看到绿色的气泡,直到它下垂为止。 注意:两个元素识别均成功。 我已经解决了cypress.io频道中提到的问题,但是我的问题并不相同。

要拖动的元素的HTML

   class="tree-item-content ng-binding ng-scope" ng-      if="!item.ui.search.html" ng-  bind="item.ItemName" ng-class="vm.itemStyle(item)" ng-dblclick="vm.treeDoubleClick ($event, item, itemParent)">Gender</

HTML for Drop Zone

 id="itl-drop-zone-down" class="dropArea" ng-class="{'itl-drop-zone-active': currentDropType === 'down' &amp;&amp; dropZoneOptions.down &amp;&amp; dropZoneOptions.down.options.length > 0, 'itl-highchart-down-drop-zone-height' : isHighchart || isWidthChart, 'itl-table-down-drop-zone-height':isVizGrid}" kendo-droptarget="" k-dragenter="onDragEnter" k-dragleave="onDragLeave" k-dragcancel="onDragLeave" k-drop="onDrop" droptype="down" data-role="droptarget">
    <span class="itl-drop-zone-header">Down</span>
    <!-- ngIf: !isInitialLayout() && displayOptions('down') -->

我在解决方案之下累了,但没有工作

describe('Drag and drop of Gender test', function() {
const dataTransfer = new DataTransfer;

function dndIt() {
  cy.get('.tree-item-content').contains("Gender")
    .trigger('dragstart', { dataTransfer });

  cy.get('#itl-drop-zone-down')
    .trigger('drop', { dataTransfer });

  cy.get('.tree-item-content').contains("Gender")
    .trigger('dragend');               
}                                      

beforeEach(function() {
  cy.viewport(1000, 600);
  cy.visit('Paste your url ');
});

it('Check whether the drag and drop of Gender is possible', function() {
  dndIt();  
  cy.get('#itl-drop-zone-down')
    .should(($el) => {
      expect($el.children()).to.have.lengthOf(1)
    });
});

});

0 个答案:

没有答案