Skip to content

Commit 9b7d464

Browse files
authored
Merge pull request #305 from magento/MQE-1185-Revert
Revert MQE-1185
2 parents e5a736a + 2953a24 commit 9b7d464

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Magento Functional Testing Framework Changelog
1717
* Fixed an issue where a test's `<after>` would run twice with Codeception `2.4.x`
1818
* Fixed an issue where tests using `extends` would not correctly override parent test steps
1919
* Test actions can now send an empty string to parameterized selectors.
20-
* Refactored `dragAndDrop` test action to correctly use given `x` and `y` arguments.
2120

2221
### GitHub Issues/Pull requests:
2322
* [#297](https://github.com/magento/magento2-functional-testing-framework/pull/297) -- Allow = to be part of the secret value

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)