Skip to content

Commit a1890ee

Browse files
kanairtomreece
authored andcommitted
MC-4418: Convert CreateProductAttributeEntityFromProductPageTest to MFTF
1 parent e7df778 commit a1890ee

9 files changed

+386
-0
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,25 @@
115115
<data key="used_for_sort_by">true</data>
116116
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
117117
</entity>
118+
<entity name="newProductAttribute" type="ProductAttribute">
119+
<data key="attribute_code" unique="suffix">attribute</data>
120+
<data key="frontend_input">Text Field</data>
121+
<data key="scope">global</data>
122+
<data key="is_required">false</data>
123+
<data key="is_unique">false</data>
124+
<data key="is_searchable">true</data>
125+
<data key="is_visible">true</data>
126+
<data key="is_visible_in_advanced_search">true</data>
127+
<data key="is_visible_on_front">true</data>
128+
<data key="is_filterable">true</data>
129+
<data key="is_filterable_in_search">true</data>
130+
<data key="used_in_product_listing">true</data>
131+
<data key="is_used_for_promo_rules">true</data>
132+
<data key="is_comparable">true</data>
133+
<data key="is_used_in_grid">true</data>
134+
<data key="is_visible_in_grid">true</data>
135+
<data key="is_filterable_in_grid">true</data>
136+
<data key="used_for_sort_by">true</data>
137+
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
138+
</entity>
118139
</entities>

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,9 @@
8181
<requiredEntity type="StoreLabel">Option9Store0</requiredEntity>
8282
<requiredEntity type="StoreLabel">Option10Store1</requiredEntity>
8383
</entity>
84+
<entity name="ProductAttributeOption8" type="ProductAttributeOption">
85+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
86+
<data key="label" unique="suffix">White</data>
87+
<data key="value" unique="suffix">white</data>
88+
</entity>
8489
</entities>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminCreateNewProductAttributeSection">
12+
<element name="saveAttribute" type="button" selector="#save"/>
13+
<element name="defaultLabel" type="input" selector="input[name='frontend_label[0]']"/>
14+
<element name="inputType" type="select" selector="select[name='frontend_input']" timeout="30"/>
15+
<element name="addValue" type="button" selector="//button[contains(@data-action,'add_new_row')]" timeout="30"/>
16+
<element name="defaultStoreView" type="input" selector="//input[contains(@name,'option[value][option_{{row}}][1]')]" parameterized="true"/>
17+
<element name="adminOption" type="input" selector="//input[contains(@name,'option[value][option_{{row}}][0]')]" parameterized="true"/>
18+
<element name="defaultRadioButton" type="radio" selector="//tr[{{row}}]//input[contains(@name,'default[]')]/..//label" parameterized="true"/>
19+
<element name="isRequired" type="checkbox" selector="//input[contains(@name,'is_required')]/..//label"/>
20+
<element name="advancedAttributeProperties" type="text" selector="//div[contains(@data-index,'advanced_fieldset')]"/>
21+
<element name="attributeCode" type="input" selector="//*[@class='admin__fieldset-wrapper-content admin__collapsible-content _show']//input[@name='attribute_code']"/>
22+
<element name="scope" type="select" selector="//*[@class='admin__fieldset-wrapper-content admin__collapsible-content _show']//select[@name='is_global']" timeout="30"/>
23+
<element name="defaultValue" type="input" selector="//*[@class='admin__fieldset-wrapper-content admin__collapsible-content _show']//input[@name='default_value_text']"/>
24+
<element name="isUnique" type="checkbox" selector="//input[contains(@name, 'is_unique')]/..//label"/>
25+
<element name="storefrontProperties" type="text" selector="//div[contains(@data-index,'front_fieldset')]"/>
26+
<element name="inSearch" type="checkbox" selector="//input[contains(@name, 'is_searchable')]/..//label"/>
27+
<element name="advancedSearch" type="checkbox" selector="//input[contains(@name, 'is_visible_in_advanced_search')]/..//label"/>
28+
<element name="isComparable" type="checkbox" selector="//input[contains(@name, 'is_comparable')]/..//label"/>
29+
<element name="allowHtmlTags" type="checkbox" selector="//input[contains(@name, 'is_html_allowed_on_front')]/..//label"/>
30+
<element name="visibleOnStorefront" type="checkbox" selector="//input[contains(@name, 'is_visible_on_front')]/..//label"/>
31+
<element name="sortProductListing" type="checkbox" selector="//input[contains(@name, 'is_visible_on_front')]/..//label"/>
32+
</section>
33+
</sections>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@
1717
<element name="FirstRow" type="button" selector="//*[@id='attributeGrid_table']/tbody/tr[1]" timeout="30"/>
1818
<element name="FilterByAttributeCode" type="input" selector="#attributeGrid_filter_attribute_code"/>
1919
<element name="attributeLabelFilter" type="input" selector="//input[@name='frontend_label']"/>
20+
<element name="attributeCodeColumn" type="text" selector="//div[@id='attributeGrid']//tbody//td[contains(@class,'col-attr-code col-attribute_code')]"/>
21+
<element name="defaultLabelColumn" type="text" selector="//div[@id='attributeGrid']//tbody//td[contains(@class,'col-label col-frontend_label')]"/>
22+
<element name="isVisibleColumn" type="text" selector="//div[@id='attributeGrid']//tbody//td[contains(@class,'a-center col-is_visible')]"/>
23+
<element name="scopeColumn" type="text" selector="//div[@id='attributeGrid']//tbody/tr/td[contains(@class,'a-center col-is_global')]"/>
24+
<element name="isSearchableColumn" type="text" selector="//div[@id='attributeGrid']//tbody/tr/td[contains(@class,'a-center col-is_searchable')]"/>
25+
<element name="isComparableColumn" type="text" selector="//div[@id='attributeGrid']//tbody/tr/td[contains(@class,'a-center col-is_comparable')]"/>
2026
</section>
2127
</sections>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
<element name="setProductAsNewFrom" type="input" selector="input[name='product[news_from_date]']"/>
5252
<element name="setProductAsNewTo" type="input" selector="input[name='product[news_to_date]']"/>
5353
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//span[text()='{{attributeLabel}}']" parameterized="true"/>
54+
<element name="attributeRequiredInput" type="input" selector="//input[contains(@name, 'product[{{attributeCode}}]')]" parameterized="true"/>
55+
<element name="attributeFieldError" type="text" selector="//*[@class='admin__field _required _error']/..//label[contains(.,'This is a required field.')]"/>
5456
<element name="customSelectField" type="select" selector="//select[@name='product[{{var}}]']" parameterized="true"/>
5557
<element name="searchCategory" type="input" selector="//*[@data-index='category_ids']//input[contains(@class, 'multiselect-search')]"/>
5658
<element name="selectCategory" type="input" selector="//*[@data-index='category_ids']//label[contains(., '{{categoryName}}')]" parameterized="true"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
<element name="asLowAs" type="input" selector="//*[@class='price-box price-final_price']/a/span[@class='price-container price-final_price tax weee']"/>
3333
<element name="productsList" type="block" selector="#maincontent .column.main"/>
3434
<element name="productName" type="text" selector=".product.name.product-item-name"/>
35+
<element name="productOptionList" type="text" selector="#narrow-by-list"/>
3536
</section>
3637
</sections>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCreateCustomProductAttributeWithDropdownFieldTest">
12+
<annotations>
13+
<stories value="Create product Attribute"/>
14+
<title value="Create Custom Product Attribute Dropdown Field (Not Required) from Product Page"/>
15+
<description value="login as admin and create configurable product attribute with Dropdown field"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-10905"/>
18+
<group value="mtf_migrated"/>
19+
</annotations>
20+
<before>
21+
<!-- Login as admin -->
22+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
23+
<!--Create Category-->
24+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
25+
<!--Create Configurable Product-->
26+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
</before>
30+
<after>
31+
<!--Delete created entity -->
32+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
33+
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
34+
<actionGroup ref="deleteProductAttribute" stepKey="deleteCreatedAttribute">
35+
<argument name="ProductAttribute" value="newProductAttribute"/>
36+
</actionGroup>
37+
<actionGroup ref="logout" stepKey="logout"/>
38+
</after>
39+
<!-- Open Product Index Page-->
40+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
41+
<waitForPageLoad stepKey="waitForProductIndexPageToLoad"/>
42+
<!-- Select Created Product-->
43+
<click stepKey="openFirstProduct" selector="{{AdminProductGridSection.productRowBySku($$createConfigProduct.sku$$)}}"/>
44+
<waitForPageLoad stepKey="waitForProductToLoad"/>
45+
<!-- Create New Product Attribute -->
46+
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickOnAddAttribute"/>
47+
<waitForPageLoad stepKey="waitForAttributePageToLoad"/>
48+
<click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="clickCreateNewAttributeButton"/>
49+
<waitForPageLoad stepKey="waitForNewAttributePageToLoad"/>
50+
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" stepKey="waitForDefaultLabelToBeVisible"/>
51+
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillAttributeLabel"/>
52+
<selectOption selector="{{AdminCreateNewProductAttributeSection.inputType}}" userInput="Dropdown" stepKey="selectInputType"/>
53+
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.addValue}}" stepKey="waitForAddValueButtonToVisible"/>
54+
<click selector="{{AdminCreateNewProductAttributeSection.addValue}}" stepKey="clickOnAddValueButton"/>
55+
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.defaultStoreView('0')}}" stepKey="waitForDefaultStoreViewToVisible"/>
56+
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultStoreView('0')}}" userInput="{{ProductAttributeOption8.label}}" stepKey="fillDefaultStoreView"/>
57+
<fillField selector="{{AdminCreateNewProductAttributeSection.adminOption('0')}}" userInput="{{ProductAttributeOption8.value}}" stepKey="fillAdminField"/>
58+
<checkOption selector="{{AdminCreateNewProductAttributeSection.defaultRadioButton('1')}}" stepKey="selectRadioButton"/>
59+
<click selector="{{AdminCreateNewProductAttributeSection.advancedAttributeProperties}}" stepKey="clickOnAdvancedAttributeProperties"/>
60+
<waitForElementVisible selector="{{AdminCreateNewProductAttributeSection.attributeCode}}" stepKey="waitForAttributeCodeToVisible"/>
61+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.attributeCode}}" stepKey="scrollToAttributeCode"/>
62+
<fillField selector="{{AdminCreateNewProductAttributeSection.attributeCode}}" userInput="{{newProductAttribute.attribute_code}}" stepKey="fillAttributeCode"/>
63+
<selectOption selector="{{AdminCreateNewProductAttributeSection.scope}}" userInput="Global" stepKey="selectScope"/>
64+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.isUnique}}" stepKey="scrollToIsUniqueOption"/>
65+
<checkOption selector="{{AdminCreateNewProductAttributeSection.isUnique}}" stepKey="enableIsUniqueOption"/>
66+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.advancedAttributeProperties}}" stepKey="scrollToAdvancedAttributeProperties"/>
67+
<click selector="{{AdminCreateNewProductAttributeSection.advancedAttributeProperties}}" stepKey="clickOnAdvancedAttributeProperties1"/>
68+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.storefrontProperties}}" stepKey="scrollToStorefrontProperties"/>
69+
<click selector="{{AdminCreateNewProductAttributeSection.storefrontProperties}}" stepKey="clickOnStorefrontProperties"/>
70+
<waitForPageLoad stepKey="waitForStoreFrontPropertiesTodiaplay"/>
71+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.sortProductListing}}" x="0" y="-80" stepKey="scroll1ToSortProductListing"/>
72+
<checkOption selector="{{AdminCreateNewProductAttributeSection.inSearch}}" stepKey="enableInSearchOption"/>
73+
<checkOption selector="{{AdminCreateNewProductAttributeSection.advancedSearch}}" stepKey="enableAdvancedSearch"/>
74+
<checkOption selector="{{AdminCreateNewProductAttributeSection.isComparable}}" stepKey="enableComparableOption"/>
75+
<checkOption selector="{{AdminCreateNewProductAttributeSection.allowHtmlTags}}" stepKey="enableAllowHtmlTags"/>
76+
<checkOption selector="{{AdminCreateNewProductAttributeSection.visibleOnStorefront}}" stepKey="enableVisibleOnStorefront"/>
77+
<checkOption selector="{{AdminCreateNewProductAttributeSection.sortProductListing}}" stepKey="enableSortProductListing"/>
78+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
79+
<click selector="{{AdminCreateNewProductAttributeSection.saveAttribute}}" stepKey="clickOnSaveAttribute"/>
80+
<waitForPageLoad stepKey="waitForAttributeToSave"/>
81+
<click selector="{{AdminProductFormSection.save}}" stepKey="saveTheProduct"/>
82+
<waitForPageLoad stepKey="waitForProductToSave"/>
83+
<see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/>
84+
<!--Verify product attribute added in product form -->
85+
<scrollTo selector="{{AdminProductFormSection.contentTab}}" stepKey="scrollToContentTab"/>
86+
<waitForElementVisible selector="{{AdminProductFormSection.attributeTab}}" stepKey="waitForAttributeToVisible"/>
87+
<click selector="{{AdminProductFormSection.attributeTab}}" stepKey="clickOnAttribute"/>
88+
<seeElement selector="{{AdminProductFormSection.attributeLabelByText(ProductAttributeFrontendLabel.label)}}" stepKey="seeAttributeLabelInProductForm"/>
89+
<!--Verify Product Attribute in Attribute Form -->
90+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
91+
<fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}" userInput="{{newProductAttribute.attribute_code}}" stepKey="setAttributeCode"/>
92+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromTheGrid"/>
93+
<waitForPageLoad stepKey="waitForPageLoad" />
94+
<see selector="{{AdminProductAttributeGridSection.attributeCodeColumn}}" userInput="{{newProductAttribute.attribute_code}}" stepKey="seeAttributeCode"/>
95+
<see selector="{{AdminProductAttributeGridSection.defaultLabelColumn}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="seeDefaultLabel"/>
96+
<see selector="{{AdminProductAttributeGridSection.isVisibleColumn}}" userInput="Yes" stepKey="seeIsVisibleColumn"/>
97+
<see selector="{{AdminProductAttributeGridSection.scopeColumn}}" userInput="Global" stepKey="seeScopeColumn"/>
98+
<see selector="{{AdminProductAttributeGridSection.isSearchableColumn}}" userInput="Yes" stepKey="seeSearchableColumn"/>
99+
<see selector="{{AdminProductAttributeGridSection.isComparableColumn}}" userInput="Yes" stepKey="seeComparableColumn"/>
100+
<!--Verify Product Attribute is present in Category Store Front Page -->
101+
<amOnPage url="$$createCategory.name$$.html" stepKey="goToStorefrontPage"/>
102+
<waitForPageLoad stepKey="waitForProductFrontPageToLoad"/>
103+
<click selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="clickOnCategory"/>
104+
<waitForPageLoad stepKey="waitForPageToLoad"/>
105+
<click selector="{{StorefrontCategoryMainSection.productLink}}" stepKey="openSearchedProduct"/>
106+
<waitForPageLoad stepKey="waitForProductToLoad1"/>
107+
<see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{ApiConfigurableProduct.name}}" stepKey="seeProductNameInStoreFront"/>
108+
<see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="{{ApiConfigurableProduct.price}}" stepKey="seeProductPriceInStoreFront"/>
109+
<see selector="{{StorefrontProductInfoMainSection.productSku}}" userInput="{{ApiConfigurableProduct.sku}}" stepKey="seeProductSkuInStoreFront"/>
110+
<scrollTo selector="{{StorefrontProductMoreInformationSection.moreInformation}}" stepKey="scrollToMoreInformation"/>
111+
<see selector="{{StorefrontProductMoreInformationSection.attributeLabel}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="seeAttributeLabel"/>
112+
<see selector="{{StorefrontProductMoreInformationSection.attributeValue}}" userInput="{{ProductAttributeOption8.value}}" stepKey="seeAttributeValue"/>
113+
<!--Verify Product Attribute present in search page -->
114+
<amOnPage url="$$createCategory.name$$.html" stepKey="goToStorefrontPage1"/>
115+
<waitForPageLoad stepKey="waitForProductFrontPageToLoad1"/>
116+
<fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{ProductAttributeOption8.value}}" stepKey="fillAttribute"/>
117+
<waitForPageLoad stepKey="waitForSearchTextBox"/>
118+
<click selector="{{StorefrontQuickSearchResultsSection.searchTextBoxButton}}" stepKey="clickSearchTextBoxButton"/>
119+
<waitForPageLoad stepKey="waitForSearchResultToLoad"/>
120+
<see selector="{{StorefrontCategoryMainSection.productName}}" userInput="{{ApiConfigurableProduct.name}}" stepKey="seeProductNameInCategoryPage"/>
121+
<see selector="{{StorefrontCategoryMainSection.productOptionList}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="seeProductAttributeOptionInCategoryPage"/>
122+
</test>
123+
</tests>

0 commit comments

Comments
 (0)