Skip to content

Commit 9f710db

Browse files
authored
Grammar and formatting
1 parent 04bc005 commit 9f710db

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

docs/custom-helpers.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
# Custom Helpers
22

3-
<div class="bs-callout bs-callout-warning" markdown="1">
4-
Due to complexity, you should only write new Custom Helpers as a last resort after trying to implement your test using built-in actions.
3+
<div class="bs-callout-warning">
4+
Due to complexity, you should only write new custom helpers as a last resort, after trying to implement your test using built-in actions.
55
</div>
66

7-
Custom Helpers allow test writers to write custom test actions to solve for advanced requirements beyond what MFTF offers out of the box.
7+
Custom Helpers allow test writers to write custom test actions to solve advanced requirements beyond what MFTF offers out of the box.
88

9-
In MFTF version 3.0.0, we removed the following test actions:
9+
In MFTF version 3.0.0, the following test actions were removed:
1010

11-
* `<executeInSelenium>`
12-
* `<performOn>`
11+
* `<executeInSelenium>`
12+
* `<performOn>`
1313

1414
These actions were removed because they allowed custom PHP code to be written inline inside of XML files. This code was difficult to read. It had no proper syntax highlighting and no linting. It was difficult to maintain, troubleshoot, and modify.
1515

1616
However, sometimes custom logic beyond what MFTF offers is necessary so we have provided an alternative solution: the `<helper>` action.
1717

1818
## Example
1919

20-
Custom Helpers are implemented in PHP files that must be placed in this directory:
21-
```
20+
Custom helpers are implemented in PHP files that must be placed in this directory:
21+
22+
```text
2223
<ModuleName>/Test/Mftf/Helper
2324
```
2425

25-
Let's take a look at one. This Custom Helper selects text on the page by this approach:
26+
This custom helper selects text on the page with this approach:
2627

27-
1. Move to a very specific X,Y starting position
28-
2. Click and hold the mouse button down
29-
3. Move to another specific X,Y position
30-
4. Release the mouse button
28+
1. Move to a very specific X,Y starting position.
29+
1. Click and hold the mouse button down.
30+
1. Move to another specific X,Y position.
31+
1. Release the mouse button.
3132

3233
This functionality is used to select text on the page and cannot be accomplished using built-in test actions.
3334

@@ -79,20 +80,21 @@ class SelectText extends Helper
7980
}
8081
```
8182

82-
### Notes About The PHP File
83+
### Notes about this PHP file
84+
85+
The following details are important about the above file:
8386

84-
The following details are important about the file above:
85-
1. The `namespace` must match the file location like `namespace Magento\PageBuilder\Test\Mftf\Helper;`
86-
2. The class must `extends Helper` and have the corresponding `use` statement to match
87-
3. You can get access to the WebDriver object via `$this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver')`
88-
4. You can implement multiple related methods in the same class.
89-
5. Specify the correct function argument types to match the types of the values you want to pass in. In this case we specified `string $context, int $startX, int $startY, int $endX, int $endY` so in the XML we will match these types.
87+
1. The `namespace` must match the file location: `namespace Magento\PageBuilder\Test\Mftf\Helper;`
88+
2. The class must `extends Helper` and have the corresponding `use` statement to match.
89+
3. You may access the WebDriver object via `$this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver')`.
90+
4. You may implement multiple related methods within the same class.
91+
5. Specify the correct function argument types to match the type of values you want to pass in. In this case, we specified `string $context, int $startX, int $startY, int $endX, int $endY`. In the XML we will match these types.
9092

91-
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.
93+
You should follow the same patterns in any custom helpers that you write yourself, but you may implement any logic or iteration that you need to solve for your use case.
9294

93-
### Referencing In A Test
95+
### Referencing in a test
9496

95-
Once you have implemented something like the above PHP file. You can then reference it in a test like this:
97+
Once you have implemented something like the above PHP file, reference it in a test:
9698

9799
```xml
98100
<helper class="\Magento\PageBuilder\Test\Mftf\Helper\SelectText" method="selectText" stepKey="selectHeadingTextInTinyMCE">
@@ -104,23 +106,23 @@ Once you have implemented something like the above PHP file. You can then refere
104106
</helper>
105107
```
106108

107-
### Notes About The XML
109+
### Notes about the XML
108110

109111
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.
110-
2. The `class` attribute matches the namespace we specified in the PHP file
111-
3. You can specify the method from the class via the `method` attribute
112-
4. If the function has a return value, it will be assigned to the stepKey variable. In this case `$selectHeadingTextInTinyMCE` would hold the return value.
112+
2. The `class` attribute matches the namespace specified in the PHP file.
113+
3. Specify the method from the class via the `method` attribute.
114+
4. If the function has a return value, it will be assigned to the `stepKey` variable. In this case, `$selectHeadingTextInTinyMCE` holds the return value.
113115
5. The types of argument values must match the PHP implementation's expected types.
114116

115-
## Key Takeaways
117+
## Key takeaways
116118

117-
Custom Helpers allow you to solve for complex use cases such as conditional logic, iteration, or complex WebDriver usage.
119+
Custom helpers allow you to solve complex use cases such as conditional logic, iteration, or complex WebDriver usage.
118120

119121
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.
120122

121-
A Custom Helper is written in a PHP file and then referenced in test XML like other actions.
123+
A custom helper is written in a PHP file and then referenced in test XML, like other actions.
122124

123-
Due to complexity, you should only use these as a last resort after trying to implement your test using built-in actions.
125+
You should only use these as a last resort after trying to implement your test using built-in actions.
124126

125127
## References
126128

0 commit comments

Comments
 (0)