@@ -10,8 +10,10 @@ The following diagram shows the structure of an MFTF action group:
1010
1111The following conventions apply to MFTF action groups:
1212
13- - All action groups are declared in XML files and stored in the ` <module>/ActionGroup/ ` directory.
14- - Every file name ends with ` ActionGroup ` , such as ` LoginToAdminActionGroup ` .
13+ - All action groups are declared in XML files and stored in the ` <module>/Test/Mftf/ActionGroup/ ` directory.
14+ - Every file name ends with ` ActionGroup ` suffix. For exampe ` LoginAsAdminActionGroup.xml ` .
15+ - Action group name should be the same as file name without extension.
16+ - Single file should contain only one ` <actionGroup> ` node
1517
1618The XML format for the ` actionGroups ` declaration is:
1719
@@ -34,32 +36,31 @@ The XML format for the `actionGroups` declaration is:
3436
3537These examples build a declaration for a group of actions that grant authorization to the Admin area, and use the declaration in a test.
3638
37- The _ Backend/ActionGroup/LoginToAdminActionGroup.xml_ ` <actionGroup> ` relates to the functionality of the _ Backend_ module.
38- In [ test] [ ] , the name and identifier of the ` <actionGroup> ` is used as a reference in the ` ref ` parameter, such as ` ref="LoginToAdminActionGroup" ` .
39+ The _ Magento/Backend/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml_ ` <actionGroup> ` relates to the functionality of the _ Magento_Backend_ module.
40+
41+ In [ test] [ ] , the name and identifier of the ` <actionGroup> ` is used as a reference in the ` ref ` parameter, such as ` ref="LoginAsAdminActionGroup" ` .
3942
4043### Create an action group declaration
4144
4245To create the ` <actionGroup> ` declaration:
4346
44- 1 . Begin with a _ Backend/ActionGroup/LoginToAdminActionGroup.xml _ template for the ` <actionGroup> ` :
47+ 1 . Begin with a template for the ` <actionGroup> ` :
4548
4649 ``` xml
4750 <?xml version =" 1.0" encoding =" UTF-8" ?>
4851
4952 <actionGroups xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5053 xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/actionGroupSchema.xsd" >
51- <actionGroup name =" LoginToAdminActionGroup " >
52- ...
54+ <actionGroup name =" {Action Group Name} " >
55+
5356 </actionGroup >
5457 </actionGroups >
5558 ```
5659
57- <!-- {% raw %} -->
58-
59601. Add actions to the `actionGroup` arguments:
6061
6162 ```xml
62- <actionGroup name =" LoginToAdminActionGroup " >
63+ <actionGroup name =" LoginAsAdminActionGroup " >
6364 <fillField stepKey =" fillUsername" selector =" #username" userInput =" {{adminUser.username}}" />
6465 <fillField stepKey =" fillPassword" selector =" #password" userInput =" {{adminUser.password}}" />
6566 <click stepKey =" click" selector =" #login" />
@@ -81,14 +82,20 @@ To create the `<actionGroup>` declaration:
8182
8283 <actionGroups xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
8384 xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/actionGroupSchema.xsd" >
84- <actionGroup name =" LoginToAdminActionGroup" >
85- <arguments >
86- <argument name =" adminUser" defaultValue =" _defaultAdmin" />
87- </arguments >
88- <fillField stepKey =" fillUsername" selector =" #username" userInput =" {{adminUser.username}}" />
89- <fillField stepKey =" fillPassword" selector =" #password" userInput =" {{adminUser.password}}" />
90- <click stepKey =" click" selector =" #login" />
91- </actionGroup >
85+ <actionGroup name =" LoginAsAdmin" >
86+ <annotations >
87+ <description >Login to Backend Admin using provided User Data. PLEASE NOTE: This Action Group does NOT validate that you are Logged In.</description >
88+ </annotations >
89+ <arguments >
90+ <argument name =" adminUser" type =" entity" defaultValue =" DefaultAdminUser" />
91+ </arguments >
92+
93+ <amOnPage url =" {{AdminLoginPage.url}}" stepKey =" navigateToAdmin" />
94+ <fillField selector =" {{AdminLoginFormSection.username}}" userInput =" {{adminUser.username}}" stepKey =" fillUsername" />
95+ <fillField selector =" {{AdminLoginFormSection.password}}" userInput =" {{adminUser.password}}" stepKey =" fillPassword" />
96+ <click selector =" {{AdminLoginFormSection.signIn}}" stepKey =" clickLogin" />
97+ <closeAdminNotification stepKey =" closeAdminNotification" />
98+ </actionGroup >
9299 </actionGroups >
93100 ```
94101
@@ -97,23 +104,23 @@ To create the `<actionGroup>` declaration:
97104In this test example, we want to add the following set of actions:
98105
99106```xml
100- <fillField stepKey = " fillUsername " selector =" # username" userInput =" {{CustomAdminUser .username}}" />
101- <fillField stepKey = " fillPassword " selector =" # password" userInput =" {{CustomAdminUser .password}}" />
102- <click stepKey = " click " selector = " #login " />
107+ <fillField selector =" {{AdminLoginFormSection. username}} " userInput =" {{adminUser .username}}" stepKey = " fillUsername " />
108+ <fillField selector =" {{AdminLoginFormSection. password}} " userInput =" {{adminUser .password}}" stepKey = " fillPassword " />
109+ <click selector = " {{AdminLoginFormSection.signIn}} " stepKey = " clickLogin " />
103110```
104111
105- Instead of adding this set of actions, use the _ LoginToAdminActionGroup _ ` <actionGroup> ` declaration in tests:
112+ Instead of adding this set of actions, use the _ LoginAsAdminActionGroup _ ` <actionGroup> ` declaration in tests:
106113
107- 1 . Reference the ` LoginToAdminActionGroup ` action group:
114+ 1 . Reference the ` LoginAsAdminActionGroup ` action group:
108115
109116 ``` xml
110- <actionGroup stepKey =" loginToAdminPanel" ref =" LoginToAdminActionGroup " />
117+ <actionGroup stepKey =" loginToAdminPanel" ref =" LoginAsAdminActionGroup " />
111118 ```
112119
1131201. Update the argument name/value pair to `adminUser` and `CustomAdminUser`:
114121
115122 ```xml
116- <actionGroup stepKey =" loginToAdminPanel" ref =" LoginToAdminActionGroup " >
123+ <actionGroup stepKey =" loginToAdminPanel" ref =" LoginAsAdminActionGroup " >
117124 <argument name =" adminUser" value =" CustomAdminUser" />
118125 </actionGroup >
119126 ```
@@ -196,30 +203,34 @@ Starting with an action group such as:
196203```
197204
198205It can be reworked into more manageable pieces, as below. These smaller steps are easier to read, update, and reuse.
199-
200- ``` xml
201- <actionGroup name =" GoToCategoryGridAndAddNewCategory" >
202- <seeInCurrentUrl url =" {{AdminCategoryPage.url}}" stepKey =" seeOnCategoryPage" />
203- <click selector =" {{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey =" clickOnAddSubCategory" />
204- <see selector =" {{AdminHeaderSection.pageTitle}}" userInput =" New Category" stepKey =" seeCategoryPageTitle" />
205- </actionGroup >
206-
207- <actionGroup name =" FillInBasicCategoryFields" >
208- <arguments >
209- <argument name =" categoryEntity" defaultValue =" _defaultCategory" />
210- </arguments >
211- <fillField selector =" {{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput =" {{categoryEntity.name}}" stepKey =" enterCategoryName" />
212- <click selector =" {{AdminCategorySEOSection.SectionHeader}}" stepKey =" openSEO" />
213- <fillField selector =" {{AdminCategorySEOSection.UrlKeyInput}}" userInput =" {{categoryEntity.name_lwr}}" stepKey =" enterURLKey" />
214- </actionGroup >
215-
216- <actionGroup name =" SaveAndVerifyCategoryCreation" >
217- <click selector =" {{AdminCategoryMainActionsSection.SaveButton}}" stepKey =" saveCategory" />
218- <seeElement selector =" {{AdminCategoryMessagesSection.SuccessMessage}}" stepKey =" assertSuccess" />
219- <seeInTitle userInput =" {{categoryEntity.name}}" stepKey =" seeNewCategoryPageTitle" />
220- <seeElement selector =" {{AdminCategorySidebarTreeSection.categoryInTree(categoryEntity.name)}}" stepKey =" seeCategoryInTree" />
221- </actionGroup >
222- ```
206+ * GoToCategoryGridAndAddNewCategory
207+ ``` xml
208+ <actionGroup name =" GoToCategoryGridAndAddNewCategory" >
209+ <seeInCurrentUrl url =" {{AdminCategoryPage.url}}" stepKey =" seeOnCategoryPage" />
210+ <click selector =" {{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey =" clickOnAddSubCategory" />
211+ <see selector =" {{AdminHeaderSection.pageTitle}}" userInput =" New Category" stepKey =" seeCategoryPageTitle" />
212+ </actionGroup >
213+ ```
214+ * FillInBasicCategoryFields
215+ ```xml
216+ <actionGroup name =" FillInBasicCategoryFields" >
217+ <arguments >
218+ <argument name =" categoryEntity" defaultValue =" _defaultCategory" />
219+ </arguments >
220+ <fillField selector =" {{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput =" {{categoryEntity.name}}" stepKey =" enterCategoryName" />
221+ <click selector =" {{AdminCategorySEOSection.SectionHeader}}" stepKey =" openSEO" />
222+ <fillField selector =" {{AdminCategorySEOSection.UrlKeyInput}}" userInput =" {{categoryEntity.name_lwr}}" stepKey =" enterURLKey" />
223+ </actionGroup >
224+ ```
225+ * SaveAndVerifyCategoryCreation
226+ ```xml
227+ <actionGroup name =" SaveAndVerifyCategoryCreation" >
228+ <click selector =" {{AdminCategoryMainActionsSection.SaveButton}}" stepKey =" saveCategory" />
229+ <seeElement selector =" {{AdminCategoryMessagesSection.SuccessMessage}}" stepKey =" assertSuccess" />
230+ <seeInTitle userInput =" {{categoryEntity.name}}" stepKey =" seeNewCategoryPageTitle" />
231+ <seeElement selector =" {{AdminCategorySidebarTreeSection.categoryInTree(categoryEntity.name)}}" stepKey =" seeCategoryInTree" />
232+ </actionGroup >
233+ ```
223234
224235<!-- {% endraw %} -->
225236
@@ -261,4 +272,4 @@ Attribute|Type|Use|Description
261272[actions]: ./actions.md
262273[test]: ../test.md
263274[`argument`]: #argument-tag
264- [ created ] : ../data.md#persist-data
275+ [created]: ../data.md#persist-data
0 commit comments