Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Selenium あるある

seya
May 30, 2018

Selenium あるある

seya

May 30, 2018
Tweet

More Decks by seya

Other Decks in Programming

Transcript

  1. Drag & Dropイベントを注入するJSで(ry browser.execute(function (selectorDrag, selectorDrop) { // function for

    triggering mouse events var fireMouseEvent = function (type, elem, centerX, centerY var evt = document.createEvent('MouseEvents'); evt.initMouseEvent(type, true, true, window, 1, 1, 1, centerX elem.dispatchEvent(evt); }; var elemDrag = document.querySelector(selectorDrag); var elemDrop = document.querySelector(selectorDrop); if (!elemDrag || !elemDrop) return false; var pos = elemDrag.getBoundingClientRect(); var center1X = Math.floor((pos.left + pos.right) / 2); ・ ・ ・