@@ -10,8 +10,10 @@ The following diagram shows the structure of an MFTF action group:
10
10
11
11
The following conventions apply to MFTF action groups:
12
12
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
15
17
16
18
The XML format for the ` actionGroups ` declaration is:
17
19
@@ -34,32 +36,31 @@ The XML format for the `actionGroups` declaration is:
34
36
35
37
These examples build a declaration for a group of actions that grant authorization to the Admin area, and use the declaration in a test.
36
38
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" ` .
39
42
40
43
### Create an action group declaration
41
44
42
45
To create the ` <actionGroup> ` declaration:
43
46
44
- 1 . Begin with a _ Backend/ActionGroup/LoginToAdminActionGroup.xml _ template for the ` <actionGroup> ` :
47
+ 1 . Begin with a template for the ` <actionGroup> ` :
45
48
46
49
``` xml
47
50
<?xml version =" 1.0" encoding =" UTF-8" ?>
48
51
49
52
<actionGroups xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
50
53
xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/actionGroupSchema.xsd" >
51
- <actionGroup name =" LoginToAdminActionGroup " >
52
- ...
54
+ <actionGroup name =" {Action Group Name} " >
55
+
53
56
</actionGroup >
54
57
</actionGroups >
55
58
```
56
59
57
- <!-- {% raw %} -->
58
-
59
60
1. Add actions to the `actionGroup` arguments:
60
61
61
62
```xml
62
- <actionGroup name =" LoginToAdminActionGroup " >
63
+ <actionGroup name =" LoginAsAdminActionGroup " >
63
64
<fillField stepKey =" fillUsername" selector =" #username" userInput =" {{adminUser.username}}" />
64
65
<fillField stepKey =" fillPassword" selector =" #password" userInput =" {{adminUser.password}}" />
65
66
<click stepKey =" click" selector =" #login" />
@@ -81,14 +82,20 @@ To create the `<actionGroup>` declaration:
81
82
82
83
<actionGroups xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
83
84
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 >
92
99
</actionGroups >
93
100
```
94
101
@@ -97,23 +104,23 @@ To create the `<actionGroup>` declaration:
97
104
In this test example, we want to add the following set of actions:
98
105
99
106
```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 " />
103
110
```
104
111
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:
106
113
107
- 1 . Reference the ` LoginToAdminActionGroup ` action group:
114
+ 1 . Reference the ` LoginAsAdminActionGroup ` action group:
108
115
109
116
``` xml
110
- <actionGroup stepKey =" loginToAdminPanel" ref =" LoginToAdminActionGroup " />
117
+ <actionGroup stepKey =" loginToAdminPanel" ref =" LoginAsAdminActionGroup " />
111
118
```
112
119
113
120
1. Update the argument name/value pair to `adminUser` and `CustomAdminUser`:
114
121
115
122
```xml
116
- <actionGroup stepKey =" loginToAdminPanel" ref =" LoginToAdminActionGroup " >
123
+ <actionGroup stepKey =" loginToAdminPanel" ref =" LoginAsAdminActionGroup " >
117
124
<argument name =" adminUser" value =" CustomAdminUser" />
118
125
</actionGroup >
119
126
```
@@ -196,30 +203,34 @@ Starting with an action group such as:
196
203
```
197
204
198
205
It 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
+ ```
223
234
224
235
<!-- {% endraw %} -->
225
236
@@ -261,4 +272,4 @@ Attribute|Type|Use|Description
261
272
[actions]: ./actions.md
262
273
[test]: ../test.md
263
274
[`argument`]: #argument-tag
264
- [ created ] : ../data.md#persist-data
275
+ [created]: ../data.md#persist-data
0 commit comments