Skip to content

Commit 0c14fdf

Browse files
committed
MQE-1993: Refactor MFTF tests/actionGroups using <executeInSelenium>
1 parent 1c615c0 commit 0c14fdf

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="DeleteDefaultCategoryChildrenActionGroup">
12+
<annotations>
13+
<description>Deletes all children categories of Default Root Category.</description>
14+
</annotations>
15+
16+
<amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToAdminCategoryPage"/>
17+
<executeInSelenium function="function ($webdriver) use ($I) {
18+
$children = $webdriver->findElements(\Facebook\WebDriver\WebDriverBy::xpath('//ul[contains(@class, \'x-tree-node-ct\')]/li[@class=\'x-tree-node\' and contains(.,
19+
\'{{DefaultCategory.name}}\')]/ul[contains(@class, \'x-tree-node-ct\')]/li//a'));
20+
while (!empty($children)) {
21+
$I->click('//ul[contains(@class, \'x-tree-node-ct\')]/li[@class=\'x-tree-node\' and contains(.,
22+
\'{{DefaultCategory.name}}\')]/ul[contains(@class, \'x-tree-node-ct\')]/li//a');
23+
$I->waitForPageLoad(30);
24+
$I->click('#delete');
25+
$I->waitForElementVisible('aside.confirm .modal-footer button.action-accept');
26+
$I->click('aside.confirm .modal-footer button.action-accept');
27+
$I->waitForPageLoad(30);
28+
$I->waitForElementVisible('#messages div.message-success', 30);
29+
$I->see('You deleted the category.', '#messages div.message-success');
30+
$children = $webdriver->findElements(\Facebook\WebDriver\WebDriverBy::xpath('//ul[contains(@class, \'x-tree-node-ct\')]/li[@class=\'x-tree-node\' and contains(.,
31+
\'{{DefaultCategory.name}}\')]/ul[contains(@class, \'x-tree-node-ct\')]/li//a'));
32+
}
33+
}" stepKey="deleteAllChildCategories"/>
34+
</actionGroup>
35+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCatalogNavigationMenuUIDesktopTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
<before>
2222
<!-- Login as admin -->
2323
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
<actionGroup ref="DeleteDefaultCategoryChildrenActionGroup" stepKey="deleteRootCategoryChildren"/>
2425
</before>
2526
<after>
27+
<actionGroup ref="DeleteDefaultCategoryChildrenActionGroup" stepKey="deleteRootCategoryChildren"/>
2628
<actionGroup ref="AdminChangeStorefrontThemeActionGroup" stepKey="changeThemeToDefault">
2729
<argument name="theme" value="{{MagentoLumaTheme.name}}"/>
2830
</actionGroup>

0 commit comments

Comments
 (0)