You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/custom-helpers.md
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Custom Helpers
2
2
3
-
Custom Helpers allow test writers to write custom test actions to solve for their advanced requirements beyond what MFTF offers out of the box.
3
+
Custom Helpers allow test writers to write custom test actions to solve for advanced requirements beyond what MFTF offers out of the box.
4
4
5
5
In MFTF version 3.0.0, we removed the following test actions:
6
6
@@ -20,9 +20,9 @@ Custom Helpers are implemented in PHP files that must be placed in this director
20
20
21
21
Let's take a look at one. This Custom Helper selects text on the page by this approach:
22
22
23
-
1. Move to a very specific X,Y starting value
23
+
1. Move to a very specific X,Y starting position
24
24
2. Click and hold the mouse button down
25
-
3. Move to another specific X,Y value
25
+
3. Move to another specific X,Y position
26
26
4. Release the mouse button
27
27
28
28
This functionality is used to select text on the page and cannot be accomplished using built-in test actions.
@@ -75,13 +75,13 @@ class SelectText extends Helper
75
75
}
76
76
```
77
77
78
-
### Important Notes About The PHP File
78
+
### Notes About The PHP File
79
79
80
80
The following details are important about the file above:
81
81
1. The `namespace` must match the file location like `namespace Magento\PageBuilder\Test\Mftf\Helper;`
82
82
2. The class must `extends Helper` and have the corresponding `use` statement to match
83
83
3. You can get access to the WebDriver object via `$this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver')`
84
-
4. You can implement multiple methods in the same class.
84
+
4. You can implement multiple related methods in the same class.
85
85
86
86
You should follow the same patterns in any Custom Helpers that you write yourself. But you can implement any logic or iteration that you need to solve for your use case.
87
87
@@ -99,7 +99,7 @@ Once you have implemented something like the above PHP file. You can then refere
99
99
</helper>
100
100
```
101
101
102
-
### Important Notes About The XML
102
+
### Notes About The XML
103
103
104
104
1. Specify an argument value for every argument that matches our PHP implementation. This allows us to pass other test data to the Custom Helper.
105
105
2. The `class` attribute matches the namespace we specified in the PHP file
@@ -110,6 +110,12 @@ Once you have implemented something like the above PHP file. You can then refere
110
110
111
111
Custom Helpers allow you to solve for complex use cases such as conditional logic, iteration, or complex WebDriver usage.
112
112
113
+
With access to the WebDriver object, you have a lot of flexibility available to you. See the [Codeception WebDriver](https://github.com/Codeception/module-webdriver/blob/master/src/Codeception/Module/WebDriver.php) for technical details and functionality available for use.
114
+
113
115
A Custom Helper is written in a PHP file and then referenced in test XML like other actions.
114
116
115
117
Due to complexity, you should only use these as a last resort after trying to implement your test using built-in actions.
118
+
119
+
## References
120
+
121
+
[Codeception WebDriver source code](https://github.com/Codeception/module-webdriver/blob/master/src/Codeception/Module/WebDriver.php) - Reference for using the WebDriver Object
0 commit comments