Skip to content

Commit cbb551c

Browse files
authored
Merge pull request #176 from magento-gl/MQE-2903
MQE-2903:Implement rapid times X clicks on UI element in MFTF
2 parents 32863c1 + 7812630 commit cbb551c

File tree

6 files changed

+80
-2
lines changed

6 files changed

+80
-2
lines changed

dev/tests/verification/Resources/DataActionsTest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class DataActionsTestCest
5858
$I->deleteEntity("createdInTest", "test"); // stepKey: deleteInTest
5959
$I->updateEntity("createdInBefore", "test", "entity",[]); // stepKey: updatedDataOutOfScope
6060
$I->deleteEntity("createdInBefore", "test"); // stepKey: deleteDataOutOfScope
61+
$I->rapidClick("#functionalTestSelector", "50"); // stepKey: rapidClickTest
6162
}
6263

6364
public function _passed(AcceptanceTester $I)

dev/tests/verification/TestModule/Test/DataActionsTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
<deleteData createDataKey="createdInTest" stepKey="deleteInTest"/>
1919
<updateData entity="entity" createDataKey="createdInBefore" stepKey="updatedDataOutOfScope"/>
2020
<deleteData createDataKey="createdInBefore" stepKey="deleteDataOutOfScope"/>
21+
<rapidClick selector="#functionalTestSelector" count="50" stepKey="rapidClickTest"/>
2122
</test>
22-
</tests>
23+
</tests>

docs/test/actions.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,25 @@ Attribute|Type|Use|Description
973973
<dragAndDrop selector1="#block1" selector2="#block2" x="50" y="50" stepKey="dragAndDrop"/>
974974
```
975975

976+
### rapidClick
977+
978+
See [rapidClick docs on codeception.com](http://codeception.com/docs/modules/WebDriver#rapidClick).
979+
980+
| Attribute | Type | Use | Description |
981+
|------------|--------|----------|-------------------------------------------------|
982+
| `selector` | string | optional | A selector for the HTML element to rapid click. |
983+
| `count` | string | required | Click count. |
984+
| `stepKey` | string | required | A unique identifier of the action. |
985+
| `before` | string | optional | `stepKey` of action that must be executed next. |
986+
| `after` | string | optional | `stepKey` of preceding action. |
987+
988+
#### Examples
989+
990+
```xml
991+
<!-- Rapid click the selected element as per given count number -->
992+
<rapidClick selector="#selector" count="50" stepKey="rapidClick"/>
993+
```
994+
976995
### executeJS
977996

978997
See [executeJS docs on codeception.com](http://codeception.com/docs/modules/WebDriver#executeJS).
@@ -1077,7 +1096,7 @@ This action can optionally contain one or more [requiredEntity](#requiredentity)
10771096
### getOTP
10781097

10791098
Generate a one-time password (OTP) based on a saved `secret` at path `magento/tfa/OTP_SHARED_SECRET` in a MFTF credential storage.
1080-
The one-time password (OTP) is returned and accessible through the stepkey.
1099+
The one-time password (OTP) is returned and accessible through the stepkey.
10811100

10821101
MFTF use TOTP from [Spomky-Labs/otphp](https://github.com/Spomky-Labs/otphp), if you want to learn more about this action.
10831102

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,21 @@ public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
792792
$action->release($tnodes)->perform();
793793
}
794794
}
795+
796+
/**
797+
* Simple rapid click as per given count number.
798+
*
799+
* @param string $selector
800+
* @param string $count
801+
* @return void
802+
* @throws \Exception
803+
*/
804+
public function rapidClick($selector, $count)
805+
{
806+
for ($i = 0; $i < $count; $i++) {
807+
$this->click($selector);
808+
}
809+
}
795810

796811
/**
797812
* Function used to fill sensitive credentials with user data, data is decrypted immediately prior to fill to avoid

src/Magento/FunctionalTestingFramework/Test/etc/actionTypeTags.xsd

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<xs:element type="closeTabType" name="closeTab" minOccurs="0" maxOccurs="unbounded"/>
3535
<xs:element type="commentType" name="comment" minOccurs="0" maxOccurs="unbounded"/>
3636
<xs:element type="dragAndDropType" name="dragAndDrop" minOccurs="0" maxOccurs="unbounded"/>
37+
<xs:element type="rapidClickType" name="rapidClick" minOccurs="0" maxOccurs="unbounded"/>
3738
<xs:element type="executeJSType" name="executeJS" minOccurs="0" maxOccurs="unbounded"/>
3839
<xs:element type="fillFieldType" name="fillField" minOccurs="0" maxOccurs="unbounded"/>
3940
<xs:element type="loadSessionSnapshotType" name="loadSessionSnapshot" minOccurs="0" maxOccurs="unbounded"/>
@@ -253,6 +254,33 @@
253254
</xs:simpleContent>
254255
</xs:complexType>
255256

257+
<xs:complexType name="rapidClickType">
258+
<xs:annotation>
259+
<xs:documentation>
260+
Performs simple mouse rapid click as per given count.
261+
</xs:documentation>
262+
</xs:annotation>
263+
<xs:simpleContent>
264+
<xs:extension base="xs:string">
265+
<xs:attribute type="xs:string" name="selector" use="required">
266+
<xs:annotation>
267+
<xs:documentation>
268+
Selector for rapid click.
269+
</xs:documentation>
270+
</xs:annotation>
271+
</xs:attribute>
272+
<xs:attribute type="xs:string" name="count" use="required">
273+
<xs:annotation>
274+
<xs:documentation>
275+
Click count.
276+
</xs:documentation>
277+
</xs:annotation>
278+
</xs:attribute>
279+
<xs:attributeGroup ref="commonActionAttributes"/>
280+
</xs:extension>
281+
</xs:simpleContent>
282+
</xs:complexType>
283+
256284
<xs:complexType name="dragAndDropType">
257285
<xs:annotation>
258286
<xs:documentation>

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
774774
$selector = $this->resolveLocatorFunctionInAttribute($selector);
775775
}
776776

777+
if (isset($customActionAttributes['count'])) {
778+
$countClickValue = $customActionAttributes['count'];
779+
$countValue = $this->addUniquenessFunctionCall($countClickValue);
780+
$countValue = $this->resolveLocatorFunctionInAttribute($countValue);
781+
}
782+
777783
if (isset($customActionAttributes['selector1']) || isset($customActionAttributes['filterSelector'])) {
778784
$selectorOneValue = $customActionAttributes['selector1'] ?? $customActionAttributes['filterSelector'];
779785
$selector1 = $this->addUniquenessFunctionCall($selectorOneValue);
@@ -1159,6 +1165,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
11591165
$y
11601166
);
11611167
break;
1168+
case "rapidClick":
1169+
$testSteps .= $this->wrapFunctionCall(
1170+
$actor,
1171+
$actionObject,
1172+
$selector,
1173+
$countValue
1174+
);
1175+
break;
11621176
case "selectMultipleOptions":
11631177
$testSteps .= $this->wrapFunctionCall(
11641178
$actor,

0 commit comments

Comments
 (0)