Skip to content

MQE-2140: [chrome81] dragAndDrop with x and y offsets no longer works #725

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 8 commits into from
Jun 12, 2020
19 changes: 10 additions & 9 deletions src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,23 +745,24 @@ public function _before(TestInterface $test)
*/
public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
{
if ($xOffset !== null || $yOffset !== null) {
$snodes = $this->matchFirstOrFail($this->baseElement, $source);
$tnodes = $this->matchFirstOrFail($this->baseElement, $target);
$snodes = $this->matchFirstOrFail($this->baseElement, $source);
$tnodes = $this->matchFirstOrFail($this->baseElement, $target);
$action = new WebDriverActions($this->webDriver);

if ($xOffset !== null || $yOffset !== null) {
$targetX = intval($tnodes->getLocation()->getX() + $xOffset);
$targetY = intval($tnodes->getLocation()->getY() + $yOffset);

$travelX = intval($targetX - $snodes->getLocation()->getX());
$travelY = intval($targetY - $snodes->getLocation()->getY());

$action = new WebDriverActions($this->webDriver);
$action->moveToElement($snodes)->perform();
$action->clickAndHold($snodes)->perform();
$action->moveByOffset($travelX, $travelY)->perform();
$action->moveToElement($snodes);
$action->clickAndHold($snodes);
$action->moveByOffset($travelX, $travelY);
$action->release()->perform();
} else {
parent::dragAndDrop($source, $target);
$action->clickAndHold($snodes);
$action->moveToElement($tnodes);
$action->release($tnodes)->perform();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this change? I remember this issue only applies for dragAndDrop with offset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for chrome 81, separating out dragAndDrop into it's native functions helped resolve couple of issues with drag and drop without offsets too, hence the fix.

Copy link
Contributor

@jilu1 jilu1 Jun 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting to know. Maybe php webdriver need to make some change? Are we on recent version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we are on latest version of php webdriver. It's probably page builder specific.

}
}

Expand Down