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/tips-tricks.md
+50Lines changed: 50 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -283,6 +283,27 @@ Use numbers within `stepKeys` when order is important, such as with testing sort
283
283
284
284
## Selectors
285
285
286
+
### Use contains() around text()
287
+
288
+
When possible, use `contains(text(), 'someTextHere')` rather than `text()='someTextHere'`.
289
+
`contains()` ignores whitespace while `text()` accounts for it.
290
+
291
+
**Why?**
292
+
If you are comparing text wihtin a selector and have an unexpected space, or a blank line above or below the string, `text()` will fail while the `contains(text())` format will catch it.
293
+
In this scenario `text()` is more exacting. Use it when you need to be very precise about what is getting compared.
294
+
295
+
<spanstyle="color:green">
296
+
GOOD:
297
+
</span>
298
+
299
+
`//span[contains(text(), 'SomeTextHere')]`
300
+
301
+
<spanstyle="color:red">
302
+
BAD:
303
+
</span>
304
+
305
+
`//span[text()='SomeTextHere']`
306
+
286
307
### Build selectors in proper order
287
308
288
309
When building selectors for form elements, start with the parent context of the form element.
@@ -353,6 +374,31 @@ BAD:
353
374
354
375
## General tips
355
376
377
+
### Use data references to avoid hardcoded values
378
+
379
+
If you need to run a command such as `<magentoCLI command="config:set" />`, do not hardcode paths and values to the command.
380
+
Rather, create an appropriate `ConfigData.xml` file, which contains the required parameters for running the command.
0 commit comments