Skip to content

Commit 52b2fe0

Browse files
committed
MAGETWO-92955: Automate with MFTF Creating a product based on a new Custom Attribute Set
1 parent aa6b899 commit 52b2fe0

9 files changed

+209
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="AdminPromptModalSection">
12+
<element name="promptField" type="input" selector="input[data-role='promptField']"/>
13+
<element name="modalOk" type="button" selector="aside.prompt .modal-footer button.action-accept" timeout="30"/>
14+
</section>
15+
</sections>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
11+
<!--Fill main fields in create product form with no weight, useful for virtual and downloadable products -->
12+
<actionGroup name="fillMainProductFormNoWeight">
13+
<arguments>
14+
<argument name="product" defaultValue="DownloadableProduct"/>
15+
</arguments>
16+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{product.name}}" stepKey="fillProductName"/>
17+
<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{product.sku}}" stepKey="fillProductSku"/>
18+
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{product.price}}" stepKey="fillProductPrice"/>
19+
<fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{product.quantity}}" stepKey="fillProductQty"/>
20+
<selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{product.status}}" stepKey="selectStockStatus"/>
21+
<selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has no weight" stepKey="selectWeight"/>
22+
</actionGroup>
23+
24+
<!--Save product and see success message-->
25+
<actionGroup name="saveProductForm">
26+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/>
27+
<see selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/>
28+
</actionGroup>
29+
</actionGroups>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<!-- Create a new attribute set -->
12+
<actionGroup name="CreateAttributeSetActionGroup">
13+
<arguments>
14+
<argument name="nameLabel" type="string"/>
15+
<argument name="basedOn" defaultValue="Default" type="string"/>
16+
</arguments>
17+
<amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="goToAttributeSets"/>
18+
<waitForPageLoad stepKey="waitForPageLoad"/>
19+
<click selector="{{AdminProductAttributeSetGridSection.addAttributeSetBtn}}" stepKey="clickAddAttributeSet"/>
20+
<fillField selector="{{AdminProductAttributeSetSection.name}}" userInput="{{nameLabel}}" stepKey="fillName"/>
21+
<selectOption selector="{{AdminProductAttributeSetSection.basedOn}}" userInput="{{basedOn}}" stepKey="selectDefaultSet"/>
22+
<click selector="{{AdminProductAttributeSetSection.save}}" stepKey="clickSave"/>
23+
<see userInput="You saved the attribute set." selector="{{AdminMessagesSection.success}}" stepKey="waitSuccessMessage"/>
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="CreateNewGroupInAttributeSetActionGroup">
12+
<arguments>
13+
<argument name="groupName" type="string" defaultValue="TestGroupName"/>
14+
</arguments>
15+
<click selector="{{AdminProductAttributeSetSection.addNewGroupBtn}}" stepKey="clickAddNewGroup"/>
16+
<waitForElementVisible selector="{{AdminPromptModalSection.promptField}}" stepKey="waitModalWindow"/>
17+
<fillField selector="{{AdminPromptModalSection.promptField}}" userInput="{{groupName}}" stepKey="fillNewGroupName"/>
18+
<click selector="{{AdminPromptModalSection.modalOk}}" stepKey="clickOkInModal"/>
19+
</actionGroup>
20+
</actionGroups>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<!-- Delete attribute set -->
12+
<actionGroup name="DeleteAttributeSetActionGroup">
13+
<arguments>
14+
<argument name="name" type="string"/>
15+
</arguments>
16+
<amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="goToAttributeSets"/>
17+
<waitForPageLoad stepKey="waitForPageLoad"/>
18+
<fillField selector="{{AdminProductAttributeSetGridSection.attributeSetNameFilter}}" userInput="{{name}}" stepKey="filterByName"/>
19+
<click selector="{{AdminProductAttributeSetGridSection.applyFilterButton}}" stepKey="clickSearch"/>
20+
<click selector="{{AdminProductAttributeSetGridSection.attributeSetRowByIndex('1')}}" stepKey="clickFirstRow"/>
21+
<waitForPageLoad stepKey="waitForPageLoad2"/>
22+
<click selector="{{AdminProductAttributeSetSection.deleteBtn}}" stepKey="clickDelete"/>
23+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
24+
<waitForPageLoad stepKey="waitForPageLoad3"/>
25+
</actionGroup>
26+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeSetGridSection.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductAttributeSetGridSection">
1212
<element name="attributeSetName" type="text" selector="//td[contains(text(), '{{var1}}')]" parameterized="true"/>
13+
<element name="attributeSetNameFilter" type="input" selector="#setGrid_filter_set_name"/>
14+
<element name="applyFilterButton" type="button" selector="#setGrid [data-action='grid-filter-apply']" timeout="30"/>
15+
<element name="attributeSetRowByIndex" type="block" selector="#setGrid_table tbody tr:nth-of-type({{var1}})" parameterized="true"/>
16+
<element name="addAttributeSetBtn" type="button" selector="button.add-set" timeout="30"/>
1317
</section>
1418
</sections>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeSetSection.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductAttributeSetSection">
12-
<element name="save" type="button" selector="button[title='Save']" />
12+
<element name="save" type="button" selector="button[title='Save']" timeout="30"/>
13+
<element name="deleteBtn" type="button" selector="button[title='Delete']" timeout="30"/>
14+
<element name="attribute" type="button" selector="//span[text()='{{var1}}']" parameterized="true"/>
15+
<element name="addNewGroupBtn" type="button" selector="button.add" timeout="30"/>
16+
<element name="name" type="input" selector="#attribute_set_name"/>
17+
<element name="basedOn" type="select" selector="#skeleton_set"/>
1318
</section>
1419
</sections>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="AdminProductFormSection">
12+
<element name="attributeSet" type="select" selector="div[data-index='attribute_set_id'] .admin__field-control"/>
13+
<element name="attributeSetFilter" type="input" selector="div[data-index='attribute_set_id'] .admin__field-control input"/>
14+
<element name="attributeSetFilterResult" type="input" selector="div[data-index='attribute_set_id'] .action-menu-item._last" timeout="30"/>
1215
<element name="productName" type="input" selector=".admin__field[data-index=name] input"/>
1316
<element name="productSku" type="input" selector=".admin__field[data-index=sku] input"/>
1417
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
@@ -22,6 +25,8 @@
2225
<element name="validationErrorLabel" type="text" selector="//label[@class='admin__field-error']"/>
2326
<element name="visibility" type="select" selector="//select[@name='product[visibility]']"/>
2427
<element name="visibilityUseDefault" type="checkbox" selector="//input[@name='use_default[visibility]']"/>
28+
<element name="divByDataIndex" type="input" selector="div[data-index='{{var}}']" parameterized="true"/>
29+
<element name="attributeSetSearchCount" type="text" selector="div[data-index='attribute_set_id'] .admin__action-multiselect-search-count"/>
2530
</section>
2631
<section name="ProductInWebsitesSection">
2732
<element name="sectionHeader" type="button" selector="div[data-index='websites']" timeout="30"/>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="AdminCreateProductCustomAttributeSet">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Add/Update attribute set"/>
15+
<title value="Admin should be able to create a simple product using a custom attribute set"/>
16+
<description value="Admin should be able to create a simple product using a custom attribute set"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MAGETWO-79284"/>
19+
<group value="catalog"/>
20+
<group value="attributeSet"/>
21+
</annotations>
22+
23+
<before>
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
25+
26+
<!-- Create the new attribute set -->
27+
<actionGroup ref="CreateAttributeSetActionGroup" stepKey="createAttributeSet">
28+
<argument name="nameLabel" value="{{ProductAttributeFrontendLabel.label}}"/>
29+
</actionGroup>
30+
<!-- Move attributes-->
31+
<dragAndDrop selector1="{{AdminProductAttributeSetSection.attribute('meta_keyword')}}" selector2="{{AdminProductAttributeSetSection.attribute('manufacturer')}}" stepKey="unassign1"/>
32+
<actionGroup ref="CreateNewGroupInAttributeSetActionGroup" stepKey="createNewGroup"/>
33+
<dragAndDrop selector1="{{AdminProductAttributeSetSection.attribute('manufacturer')}}" selector2="{{AdminProductAttributeSetSection.attribute('TestGroupName')}}" stepKey="assignManufacturer"/>
34+
<click selector="{{AdminProductAttributeSetSection.save}}" stepKey="clickSave2"/>
35+
</before>
36+
37+
<after>
38+
<!-- Delete the new attribute set -->
39+
<actionGroup ref="DeleteAttributeSetActionGroup" stepKey="deleteAttributeSet">
40+
<argument name="name" value="{{ProductAttributeFrontendLabel.label}}"/>
41+
</actionGroup>
42+
43+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
44+
</after>
45+
46+
<!-- Go to new product page and see a default attribute -->
47+
<amOnPage url="{{AdminProductCreatePage.url('4', 'simple')}}" stepKey="goToNewProductPage"/>
48+
<waitForPageLoad stepKey="wait2"/>
49+
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="expandSEOSection"/>
50+
<seeElementInDOM selector="{{AdminProductFormSection.divByDataIndex('meta_keyword')}}" stepKey="seeMetaKeyword"/>
51+
<dontSeeElementInDOM selector="{{AdminProductFormSection.divByDataIndex('testgroupname')}}" stepKey="dontSeeTestGroupName"/>
52+
53+
<!-- Switch from default attribute set to new attribute set -->
54+
<!-- A scrollToTopOfPage is needed to hide the floating header -->
55+
<scrollToTopOfPage stepKey="scrollToTop"/>
56+
<click selector="{{AdminProductFormSection.attributeSet}}" stepKey="startEditAttrSet"/>
57+
<fillField selector="{{AdminProductFormSection.attributeSetFilter}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="searchForAttrSet"/>
58+
<waitForElementVisible selector="{{AdminProductFormSection.attributeSetSearchCount}}" stepKey="waitLoadOption"/>
59+
<click selector="{{AdminProductFormSection.attributeSetFilterResult}}" stepKey="selectAttrSet"/>
60+
61+
<!-- See new attribute set -->
62+
<seeElementInDOM selector="{{AdminProductFormSection.divByDataIndex('testgroupname')}}" stepKey="seeTestGroupName"/>
63+
<dontSeeElementInDOM selector="{{AdminProductFormSection.divByDataIndex('meta_keyword')}}" stepKey="dontSeeMetaKeyword"/>
64+
65+
<!-- Finish filling the new product page -->
66+
<actionGroup ref="fillMainProductFormNoWeight" stepKey="fillSimpleProductMain">
67+
<argument name="product" value="_defaultProduct"/>
68+
</actionGroup>
69+
<actionGroup ref="saveProductForm" stepKey="saveSimpleProduct"/>
70+
71+
<!-- Check the storefront -->
72+
<amOnPage url="{{_defaultProduct.name}}.html" stepKey="goToProductPage"/>
73+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
74+
<seeInTitle userInput="{{_defaultProduct.name}}" stepKey="seeProductNameInTitlte"/>
75+
<see userInput="{{_defaultProduct.name}}" selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="assertProductName"/>
76+
<see userInput="{{_defaultProduct.sku}}" selector="{{StorefrontProductInfoMainSection.productSku}}" stepKey="assertProductSku"/>
77+
<see userInput="${{_defaultProduct.price}}" selector="{{StorefrontProductInfoMainSection.productPrice}}" stepKey="assertProductPrice"/>
78+
</test>
79+
</tests>

0 commit comments

Comments
 (0)