Skip to content

Commit 3da7be5

Browse files
committed
Revert "MQE-1185: MFTF DragAndDrop Action Is Not Using X, Y Offsets Correctly"
This reverts commit 2fe867c.
1 parent e5a736a commit 3da7be5

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

+13-19
Original file line numberDiff line numberDiff line change
@@ -599,29 +599,23 @@ public function _before(TestInterface $test)
599599
*/
600600
public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
601601
{
602-
if ($xOffset === null && $yOffset === null) {
603-
parent::dragAndDrop($source, $target);
604-
} else {
605-
$sNode = $this->matchFirstOrFail($this->baseElement, $source);
606-
$tNode = $this->matchFirstOrFail($this->baseElement, $target);
602+
if ($xOffset !== null || $yOffset !== null) {
603+
$snodes = $this->matchFirstOrFail($this->baseElement, $source);
604+
$tnodes = $this->matchFirstOrFail($this->baseElement, $target);
607605

608-
$sHeight = $sNode->getSize()->getHeight();
609-
$sWidth = $sNode->getSize()->getWidth();
606+
$targetX = intval($tnodes->getLocation()->getX() + $xOffset);
607+
$targetY = intval($tnodes->getLocation()->getY() + $yOffset);
610608

611-
$travelX = intval($tNode->getLocation()->getX() - $sNode->getLocation()->getX() + $xOffset);
612-
$travelY = intval($tNode->getLocation()->getY() - $sNode->getLocation()->getY() + $yOffset);
609+
$travelX = intval($targetX - $snodes->getLocation()->getX());
610+
$travelY = intval($targetY - $snodes->getLocation()->getY());
613611

614612
$action = new WebDriverActions($this->webDriver);
615-
if ($travelX >0 && $travelY >0 && $travelX < $sWidth && $travelY < $sHeight) {
616-
// Perform separate action steps when dragging and dropping inside the source element boundary
617-
$action->moveToElement($sNode)->perform();
618-
$action->clickAndHold($sNode)->perform();
619-
$action->moveByOffset($travelX, $travelY)->perform();
620-
$action->release()->perform();
621-
} else {
622-
// Call dragAndDropBy otherwise
623-
$action->dragAndDropBy($sNode, $travelX, $travelY)->perform();
624-
}
613+
$action->moveToElement($snodes)->perform();
614+
$action->clickAndHold($snodes)->perform();
615+
$action->moveByOffset($travelX, $travelY)->perform();
616+
$action->release()->perform();
617+
} else {
618+
parent::dragAndDrop($source, $target);
625619
}
626620
}
627621

0 commit comments

Comments
 (0)