Each grab* method returns either array or a string or whatever... and this is a problem. For CodeceptJS 3.0 we need to unify API so the result of those methods will be predictable.
We need to go through helpers:
- WebDriver
- Puppeteer
- Appium
- TestCafe
- Nightmare
- Protractor
and go through following grab* methods and implement a new method which ALWAYS returns an array:
grabAttributeFrom rename to grabAttributeFromAll => returns array
grabCssPropertyFrom rename to grabCssPropertyFromAll => returns array
grabHTMLFrom rename to grabHTMLFromAll => returns array
grabTextFrom rename to grabTextFromAll => returns array
grabValueFrom rename to grabValueFromAll => returns array
While all current methods should always return value for the first element:
grabAttributeFrom returns value of the FIRST element
grabCssPropertyFrom returns value of the FIRST element
grabHTMLFrom returns value of the FIRST element
grabTextFrom returns value of the FIRST element
grabValueFrom returns value of the FIRST element
For each of new / old methods write corresponding tests in:
tests/helper/webapi.js
tests/helper/HELPERNAME.js
Workflow
Development
- Open a helper
- Find a corresponding grab* method
- Rename it to grab*All
- Make sure it returns an array
- Create a new method grab*
- Call grab*All from it, and return a single value
Testing
- find corresponding test for the method in tests/helpers/*
- change test for grab* to match single value only
- add a new test for grab*All
Documentation
- update docs in
docs/webapi/grab* to say "returns a single value (string)"
- copy documentation to
docs/webapi/grab*All to say "returns an array"
- add
{{> grab*All }} into grab*All method docblock
Alternative implementation
Just an idea, to save time we can just add { all: true} parameter to the list of arguments for each grab* function. So it can be:
grabTextFrom('.user'); // returns first text
grabTextFrom('.user', { all: true }); // returns array
This implementation is simpler as we will need less tests and less methods documented
Each
grab*method returns either array or a string or whatever... and this is a problem. For CodeceptJS 3.0 we need to unify API so the result of those methods will be predictable.We need to go through helpers:
and go through following
grab*methods and implement a new method which ALWAYS returns an array:grabAttributeFromrename tograbAttributeFromAll=> returns arraygrabCssPropertyFromrename tograbCssPropertyFromAll=> returns arraygrabHTMLFromrename tograbHTMLFromAll=> returns arraygrabTextFromrename tograbTextFromAll=> returns arraygrabValueFromrename tograbValueFromAll=> returns arrayWhile all current methods should always return value for the first element:
grabAttributeFromreturns value of the FIRST elementgrabCssPropertyFromreturns value of the FIRST elementgrabHTMLFromreturns value of the FIRST elementgrabTextFromreturns value of the FIRST elementgrabValueFromreturns value of the FIRST elementFor each of new / old methods write corresponding tests in:
tests/helper/webapi.jstests/helper/HELPERNAME.jsWorkflow
Development
Testing
Documentation
docs/webapi/grab*to say "returns a single value (string)"docs/webapi/grab*Allto say "returns an array"{{> grab*All }}intograb*Allmethod docblockAlternative implementation
Just an idea, to save time we can just add
{ all: true}parameter to the list of arguments for each grab* function. So it can be:This implementation is simpler as we will need less tests and less methods documented