Skip to content
Merged
Show file tree
Hide file tree
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: 1 addition & 0 deletions dev/tests/verification/Resources/BasicFunctionalTest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class BasicFunctionalTestCest
$I->dontSeeOptionIsSelected(".functionalTestSelector", "someInput");
$I->doubleClick(".functionalTestSelector");
$I->dragAndDrop(".functionalTestSelector", ".functionalTestSelector2");
$I->dragAndDrop(".functionalTestSelector", ".functionalTestSelector2", 100, 900);
$executeJSKey1 = $I->executeJS("someJSFunction");
$I->fillField(".functionalTestSelector", "someInput");
$I->fillField(".functionalTestSelector", "0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<dontSeeOptionIsSelected selector=".functionalTestSelector" userInput="someInput" stepKey="dontSeeOptionIsSelectedKey1" />
<doubleClick selector=".functionalTestSelector" stepKey="doubleClickKey1"/>
<dragAndDrop selector1=".functionalTestSelector" selector2=".functionalTestSelector2" stepKey="dragAndDropKey1" />
<dragAndDrop selector1=".functionalTestSelector" selector2=".functionalTestSelector2" stepKey="dragAndDropKey2" x="100" y="900"/>
<executeJS function="someJSFunction" stepKey="executeJSKey1"/>
<fillField selector=".functionalTestSelector" userInput="someInput" stepKey="fillFieldKey1" />
<fillField selector=".functionalTestSelector" userInput="0" stepKey="fillFieldKey2" />
Expand Down
31 changes: 31 additions & 0 deletions src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Facebook\WebDriver\WebDriverSelect;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\Exception\NoSuchElementException;
use Facebook\WebDriver\Interactions\WebDriverActions;
use Codeception\Exception\ElementNotFound;
use Codeception\Exception\ModuleConfigException;
use Codeception\Exception\ModuleException;
Expand Down Expand Up @@ -526,6 +527,36 @@ public function _before(TestInterface $test)
parent::_before($test);
}

/**
* Override for codeception's default dragAndDrop to include offset options.
* @param string $source
* @param string $target
* @param int $xOffset
* @param int $yOffset
* @return void
*/
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);

$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->release()->perform();
} else {
parent::dragAndDrop($source, $target);
}
}

/**
* Override for _failed method in Codeception method. Adds png and html attachments to allure report
* following parent execution of test failure processing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,22 @@
<xs:documentation>
End point selector for drag-and-drop.
</xs:documentation>
</xs:annotation></xs:attribute>
</xs:annotation>
</xs:attribute>
<xs:attribute type="xs:string" name="x">
<xs:annotation>
<xs:documentation>
X offset for drag-and-drop destination.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute type="xs:string" name="y">
<xs:annotation>
<xs:documentation>
Y offset for drag-and-drop destination.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="commonActionAttributes"/>
</xs:extension>
</xs:simpleContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $parameterArray, $button);
break;
case "dragAndDrop":
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector1, $selector2);
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector1, $selector2, $x, $y);
break;
case "selectMultipleOptions":
$testSteps .= $this->wrapFunctionCall(
Expand Down