Skip to content

Commit 0919abe

Browse files
committed
MQE-1185: MFTF DragAndDrop Action Is Not Using X, Y Offsets Correctly
1 parent af48714 commit 0919abe

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,17 +596,42 @@ public function _before(TestInterface $test)
596596
*/
597597
public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
598598
{
599-
if ($xOffset !== null || $yOffset !== null) {
599+
if ($xOffset === null && $yOffset === null) {
600+
parent::dragAndDrop($source, $target);
601+
} else {
600602
$snodes = $this->matchFirstOrFail($this->baseElement, $source);
601603
$tnodes = $this->matchFirstOrFail($this->baseElement, $target);
602604

605+
$sHeight = $snodes->getSize()->getHeight();
606+
$sWidth = $snodes->getSize()->getWidth();
607+
608+
echo '$sHeight = ' . $sHeight . PHP_EOL;
609+
echo '$sWidth = ' . $sWidth . PHP_EOL;
610+
611+
echo '$tHeight = ' . $tnodes->getSize()->getHeight() . PHP_EOL;
612+
echo '$tWidth = ' . $tnodes->getSize()->getWidth() . PHP_EOL;
613+
614+
echo '$sX = ' . $snodes->getLocation()->getX() . PHP_EOL;
615+
echo '$sY = ' . $snodes->getLocation()->getY() . PHP_EOL;
616+
617+
echo '$tX = ' . $tnodes->getLocation()->getX() . PHP_EOL;
618+
echo '$tY = ' . $tnodes->getLocation()->getY() . PHP_EOL;
619+
603620
$travelX = intval($tnodes->getLocation()->getX() - $snodes->getLocation()->getX() + $xOffset);
604621
$travelY = intval($tnodes->getLocation()->getY() - $snodes->getLocation()->getY() + $yOffset);
605622

623+
echo '$travelX = ' . $travelX . PHP_EOL;
624+
echo '$travelY = ' . $travelY . PHP_EOL;
625+
606626
$action = new WebDriverActions($this->webDriver);
607-
$action->dragAndDropBy($snodes, $travelX, $travelY)->perform();
608-
} else {
609-
parent::dragAndDrop($source, $target);
627+
if ($travelX >0 && $travelY >0 && $travelX < $sWidth && $travelY < $sHeight) {
628+
$action->moveToElement($snodes)->perform();
629+
$action->clickAndHold($snodes)->perform();
630+
$action->moveByOffset($travelX, $travelY)->perform();
631+
$action->release()->perform();
632+
} else {
633+
$action->dragAndDropBy($snodes, $travelX, $travelY)->perform();
634+
}
610635
}
611636
}
612637

0 commit comments

Comments
 (0)