0

Trying to perform drag and drop action using the protractor, in this case, elements are in two different frames because of that not able to perform drag and drop action.

We have tried all the traditional way to perform an action but doesn't help any of those.

Below code, we have tried

const modify = 'function e(e,t,n,i){var r=a.createEvent("DragEvent");r.initMouseEvent(t,!0,!0,o,0,0,0,c,g,!1,!1,!1,!1,0,null),Object.defineProperty(r,"dataTransfer",{get:function(){return d}}),e.dispatchEvent(r),o.setTimeout(i,n)}var iframe4 = document.getElementById("_iframeleftPaneW");var innerDoc4 = iframe4.contentDocument || iframe4.contentWindow.document;var iframe5 = document.getElementById("Report");var innerDoc5 = iframe5.contentDocument || iframe5.contentWindow.document;var t=innerDoc4.querySelector(arguments[0]),n=innerDoc5.querySelector(arguments[1]),i=arguments[2]||0,r=arguments[3]||0;if(!t.draggable)throw new Error("Source element is not draggable.");var a=t.ownerDocument,o=a.defaultView,l=t.getBoundingClientRect(),u=n?n.getBoundingClientRect():l,c=l.left+(l.width>>1),g=l.top+(l.height>>1),s=u.left+(u.width>>1)+i,f=u.top+(u.height>>1)+r,d=Object.create(Object.prototype,{_items:{value:{}},effectAllowed:{value:"all",writable:!0},dropEffect:{value:"move",writable:!0},files:{get:function(){return this._items.Files}},types:{get:function(){return Object.keys(this._items)}},setData:{value:function(e,t){this._items[e]=t}},getData:{value:function(e){return this._items[e]}},clearData:{value:function(e){delete this._items[e]}},setDragImage:{value:function(e){}}});if(n=a.elementFromPoint(s,f),!n)throw new Error("The target element is not interactable and need to be scrolled into the view.");u=n.getBoundingClientRect(),e(t,"dragstart",101,function(){var i=n.getBoundingClientRect();c=i.left+s-u.left,g=i.top+f-u.top,e(n,"dragenter",1,function(){e(n,"dragover",101,function(){n=a.elementFromPoint(c,g),e(n,"drop",1,function(){e(t,"dragend",1,callback)})})})})'
browser.executeScript(modify,"cssSelectorOfSourceElement","cssSelectorOfTargetElement");

Expected action to perform drag and drop action even if element present in different frames action needs to perform without error

Murali
  • 23
  • 2
  • 8
  • It seems that the problem was already solved. See here: https://stackoverflow.com/questions/14692448/drag-drop-elements-between-parent-frame-and-child-iframe – Kacper Aug 22 '19 at 07:05
  • Thanks for the sharing, this solution already l have looked in and I'm not sure how to implement in protractor and I'm new to coding, will you please provide any snippet to implement in protractor? – Murali Aug 22 '19 at 11:15

0 Answers0