Skip to content

Revert MQE-1185 #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ Magento Functional Testing Framework Changelog
* Fixed an issue where a test's `<after>` would run twice with Codeception `2.4.x`
* Fixed an issue where tests using `extends` would not correctly override parent test steps
* Test actions can now send an empty string to parameterized selectors.
* Refactored `dragAndDrop` test action to correctly use given `x` and `y` arguments.

### GitHub Issues/Pull requests:
* [#297](https://github.com/magento/magento2-functional-testing-framework/pull/297) -- Allow = to be part of the secret value
32 changes: 13 additions & 19 deletions src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
Original file line number Diff line number Diff line change
@@ -599,29 +599,23 @@ public function _before(TestInterface $test)
*/
public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
{
if ($xOffset === null && $yOffset === null) {
parent::dragAndDrop($source, $target);
} else {
$sNode = $this->matchFirstOrFail($this->baseElement, $source);
$tNode = $this->matchFirstOrFail($this->baseElement, $target);
if ($xOffset !== null || $yOffset !== null) {
$snodes = $this->matchFirstOrFail($this->baseElement, $source);
$tnodes = $this->matchFirstOrFail($this->baseElement, $target);

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

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

$action = new WebDriverActions($this->webDriver);
if ($travelX >0 && $travelY >0 && $travelX < $sWidth && $travelY < $sHeight) {
// Perform separate action steps when dragging and dropping inside the source element boundary
$action->moveToElement($sNode)->perform();
$action->clickAndHold($sNode)->perform();
$action->moveByOffset($travelX, $travelY)->perform();
$action->release()->perform();
} else {
// Call dragAndDropBy otherwise
$action->dragAndDropBy($sNode, $travelX, $travelY)->perform();
}
$action->moveToElement($snodes)->perform();
$action->clickAndHold($snodes)->perform();
$action->moveByOffset($travelX, $travelY)->perform();
$action->release()->perform();
} else {
parent::dragAndDrop($source, $target);
}
}