angularjs - Protractor: Drag-Drop function working with Mozilla and chrome but not with Internet Explorer 11 -
i trying automate drag-drop action using protractor. element's properties are:
element needs dragged:
<li id="activities-test123" class="ng-binding ng-scope ng-isolate-scope draggable" tooltip-placement="right" ng-attr-tooltip="{{activity.name.length > relationships.namelimit ? activity.name : ''}}" draggable="true" ng-class="{'draggable-disabled': activity.entityhasactivity, 'draggable': !activity.entityhasactivity}" ng-repeat="activity in relationships.activities | toarray:false | filter:searchactivities:strict" tooltip="">
the location element needs dropped:
<div class="tree-view ng-isolate-scope" drop="relationships.handledrop" datasource="relationships" droppable=""> <p class="content-help-text ng-hide" ng-hide="relationships.hasentity()">drag entity here</p> <div ui-tree="relationships.options"> <ol class="top-level ng-isolate-scope" droppable="" ui-tree-nodes=""> <!-- ngrepeat: item in relationships.tree --> </ol> </div> </div>
i using drag-drop-helper native script found in github
module.exports =function simulatedragdrop(sourcenode, destinationnode) { var event_types = { drag_end: 'dragend', drag_start: 'dragstart', drop: 'drop' } function createcustomevent(type) { var event = new customevent("customevent") event.initcustomevent(type, true, true, null) event.datatransfer = { data: { }, setdata: function(type, val) { this.data[type] = val }, getdata: function(type) { return this.data[type] } } return event } function dispatchevent(node, type, event) { if (node.dispatchevent) { return node.dispatchevent(event) } if (node.fireevent) { return node.fireevent("on" + type, event) } } var event = createcustomevent(event_types.drag_start) dispatchevent(sourcenode, event_types.drag_start, event) var dropevent = createcustomevent(event_types.drop) dropevent.datatransfer = event.datatransfer dispatchevent(destinationnode, event_types.drop, dropevent) var dragendevent = createcustomevent(event_types.drag_end) dragendevent.datatransfer = event.datatransfer dispatchevent(sourcenode, event_types.drag_end, dragendevent) }
the problem drag-drop action working in mozilla , chrome browsers. giving error: unknownerror: javascript error (warning: server did not provide stacktrace information) on running browser.executescript command in internet explorer 11.
i implementing code in following way:
var draganddrop = require("./../native_js_drag_and_drop_helper.js"); var input = element(by.xpath("xpath of element moved")); var target = element(by.xpath("xpath of target location")); browser.executescript(draganddrop, input.getwebelement(), target.getwebelement());
i verified browser.executescript command running browser.executescript('javascript:localstorage.clear(); alert("helloworld");');
, working fine ie11.
can give me idea missing here?
i got error fixed.
ie 11 browser doesn't support customevent constructor in line:var event = new customevent("customevent")
.
change customevent createevent. var event=document.createevent("customevent");
. works charm!!
Comments
Post a Comment