Skip to content

Commit 4ada037

Browse files
committed
MQE-715: searchAndMultiSelectOption action should work for advanced customer group selector in B2B
- add new selectMultipleOptions function - update test generator to handle new function
1 parent 9efd2ee commit 4ada037

File tree

7 files changed

+76
-13
lines changed

7 files changed

+76
-13
lines changed

dev/tests/verification/Resources/BasicFunctionalTest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class BasicFunctionalTestCest
131131
$I->seeNumberOfElements(".functionalTestSelector");
132132
$I->seeOptionIsSelected(".functionalTestSelector", "someInput");
133133
$I->selectOption(".functionalTestSelector");
134+
$I->selectMultipleOptions(".filter", ".option", ['opt1', 'opt2']);
134135
$I->setCookie("someInput", "someCookieValue");
135136
$I->switchToIFrame("someInput");
136137
$I->switchToNextTab();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
<seeNumberOfElements selector=".functionalTestSelector" stepKey="seeNumberOfElementsKey1"/>
9393
<seeOptionIsSelected selector=".functionalTestSelector" userInput="someInput" stepKey="seeOptionIsSelectedKey1" />
9494
<selectOption selector=".functionalTestSelector" stepKey="selectOptionKey1"/>
95+
<selectMultipleOptions filterSelector=".filter" optionSelector=".option" stepKey="selectMultipleOpts1">
96+
<array>['opt1', 'opt2']</array>
97+
</selectMultipleOptions>
9598
<setCookie value="someCookieValue" userInput="someInput" stepKey="setCookieKey1" />
9699
<switchToIFrame userInput="someInput" stepKey="switchToIFrameKey1"/>
97100
<switchToNextTab stepKey="switchToNextTabKey1"/>

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,34 @@ public function searchAndMultiSelectOption($select, array $options, $requireActi
271271
$this->waitForPageLoad();
272272
$this->waitForElementVisible($selectDropdown);
273273
$this->click($selectDropdown);
274+
275+
$this->selectMultipleOptions($selectSearchText, $selectSearchResult, $options);
276+
277+
if ($requireAction) {
278+
$selectAction = $select . ' button[class=action-default]';
279+
$this->waitForPageLoad();
280+
$this->click($selectAction);
281+
}
282+
}
283+
284+
/**
285+
* Select multiple options from a drop down using a filter and text field to narrow results.
286+
*
287+
* @param string $selectSearchTextField
288+
* @param string $selectSearchResult
289+
* @param string[] $options
290+
* @return void
291+
*/
292+
public function selectMultipleOptions($selectSearchTextField, $selectSearchResult, array $options)
293+
{
274294
foreach ($options as $option) {
275295
$this->waitForPageLoad();
276-
$this->fillField($selectSearchText, '');
296+
$this->fillField($selectSearchTextField, '');
277297
$this->waitForPageLoad();
278-
$this->fillField($selectSearchText, $option);
298+
$this->fillField($selectSearchTextField, $option);
279299
$this->waitForPageLoad();
280300
$this->click($selectSearchResult);
281301
}
282-
if ($requireAction) {
283-
$selectAction = $select . ' button[class=action-default]';
284-
$this->waitForPageLoad();
285-
$this->click($selectAction);
286-
}
287302
}
288303

289304
/**

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function resolveReferences()
205205
}
206206

207207
/**
208-
* Flattens expectedResult/actualResults nested elements, if necessary.
208+
* Flattens expectedResult/actualResults/array nested elements, if necessary.
209209
* e.g. expectedResults[] -> ["expectedType" => "string", "expected" => "value"]
210210
* Warns user if they are using old Assertion syntax.
211211
*
@@ -215,6 +215,11 @@ public function trimAssertionAttributes()
215215
{
216216
$actionAttributeKeys = array_keys($this->actionAttributes);
217217

218+
// Flatten AssertSorted "array" element to parameterArray
219+
if (isset($this->actionAttributes["array"])) {
220+
$this->resolvedCustomAttributes['parameterArray'] = $this->actionAttributes['array']['value'];
221+
}
222+
218223
/** MQE-683 DEPRECATE OLD METHOD HERE
219224
* Checks if action has any of the old, single line attributes
220225
* Throws a warning and returns, assuming old syntax is used.

src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<xs:element type="magentoCLIType" name="magentoCLI" minOccurs="0" maxOccurs="unbounded"/>
1515
<xs:element type="closeAdminNotificationType" name="closeAdminNotification" minOccurs="0" maxOccurs="unbounded"/>
1616
<xs:element type="searchAndMultiSelectOptionType" name="searchAndMultiSelectOption" minOccurs="0" maxOccurs="unbounded"/>
17+
<xs:element type="selectMultipleOptionsType" name="selectMultipleOptions" minOccurs="0" maxOccurs="unbounded"/>
1718
<xs:element type="formatMoneyType" name="formatMoney" minOccurs="0" maxOccurs="unbounded"/>
1819
<xs:element type="parseFloatType" name="parseFloat" minOccurs="0" maxOccurs="unbounded"/>
1920
<xs:element type="mSetLocaleType" name="mSetLocale" minOccurs="0" maxOccurs="unbounded"/>
@@ -80,6 +81,32 @@
8081
</xs:simpleContent>
8182
</xs:complexType>
8283

84+
<xs:complexType name="selectMultipleOptionsType">
85+
<xs:annotation>
86+
<xs:documentation>
87+
Selects all given options in given Magento dropdown element.
88+
</xs:documentation>
89+
</xs:annotation>
90+
<xs:choice maxOccurs="unbounded">
91+
<xs:element name="array" type="xs:string" minOccurs="0"/>
92+
</xs:choice>
93+
<xs:attribute type="xs:string" name="filterSelector" use="required">
94+
<xs:annotation>
95+
<xs:documentation>
96+
The selector for the text filter field.
97+
</xs:documentation>
98+
</xs:annotation>
99+
</xs:attribute>
100+
<xs:attribute type="xs:string" name="optionSelector" use="required">
101+
<xs:annotation>
102+
<xs:documentation>
103+
The selector used to select the corresponding options based on the filter field.
104+
</xs:documentation>
105+
</xs:annotation>
106+
</xs:attribute>
107+
<xs:attributeGroup ref="commonActionAttributes"/>
108+
</xs:complexType>
109+
83110
<xs:complexType name="formatMoneyType">
84111
<xs:annotation>
85112
<xs:documentation>

src/Magento/FunctionalTestingFramework/Util/ModuleResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private function printMagentoVersionInfo()
247247
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
248248
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
249249
$response = curl_exec($ch);
250-
print "Version Information: {$response}\n";
250+
print "\nVersion Information: {$response}\n";
251251
}
252252

253253
/**

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,15 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
505505
$selector = $this->resolveLocatorFunctionInAttribute($selector);
506506
}
507507

508-
if (isset($customActionAttributes['selector1'])) {
509-
$selector1 = $this->addUniquenessFunctionCall($customActionAttributes['selector1']);
508+
if (isset($customActionAttributes['selector1']) || isset($customActionAttributes['filterSelector'])) {
509+
$selectorOneValue = $customActionAttributes['selector1'] ?? $customActionAttributes['filterSelector'];
510+
$selector1 = $this->addUniquenessFunctionCall($selectorOneValue);
510511
$selector1 = $this->resolveLocatorFunctionInAttribute($selector1);
511512
}
512513

513-
if (isset($customActionAttributes['selector2'])) {
514-
$selector2 = $this->addUniquenessFunctionCall($customActionAttributes['selector2']);
514+
if (isset($customActionAttributes['selector2']) || isset($customActionAttributes['optionSelector'])) {
515+
$selectorTwoValue = $customActionAttributes['selector2'] ?? $customActionAttributes['optionSelector'];
516+
$selector2 = $this->addUniquenessFunctionCall($selectorTwoValue);
515517
$selector2 = $this->resolveLocatorFunctionInAttribute($selector2);
516518
}
517519

@@ -876,6 +878,16 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
876878
case "dragAndDrop":
877879
$testSteps .= $this->wrapFunctionCall($actor, $actionName, $selector1, $selector2);
878880
break;
881+
case "selectMultipleOptions":
882+
$testSteps .= $this->wrapFunctionCall(
883+
$actor,
884+
$actionName,
885+
$selector1,
886+
$selector2,
887+
$input,
888+
$parameterArray
889+
);
890+
break;
879891
case "executeInSelenium":
880892
$testSteps .= $this->wrapFunctionCall($actor, $actionName, $function);
881893
break;

0 commit comments

Comments
 (0)