/** * Drag one element onto another. * * @param string $sourceXpath * @param string $destinationXpath */ public function dragTo($sourceXpath, $destinationXpath) { $source = $this->wdSession->element('xpath', $sourceXpath); $destination = $this->wdSession->element('xpath', $destinationXpath); $this->wdSession->moveto(array('element' => $source->getID())); $script = <<<JS (function (element) { var event = document.createEvent("HTMLEvents"); event.initEvent("dragstart", true, true); event.dataTransfer = {}; element.dispatchEvent(event); }({{ELEMENT}})); JS; $this->withSyn()->executeJsOnXpath($sourceXpath, $script); $this->wdSession->buttondown(); $this->wdSession->moveto(array('element' => $destination->getID())); $this->wdSession->buttonup(); $script = <<<JS (function (element) { var event = document.createEvent("HTMLEvents"); event.initEvent("drop", true, true); event.dataTransfer = {}; element.dispatchEvent(event); }({{ELEMENT}})); JS; $this->withSyn()->executeJsOnXpath($destinationXpath, $script); }