Description
Allow custom code generation from CodeGenerator.
We have a library of components that we typically use test-id's. The id itself is not always on the actual "input" element for various reasons (like using 3rd party component where we don't have the ability easily). Also, sometimes we have upgraded the library the DOM structure of those components has changed.
To resolve this, we created our own matching set of "component test library" that allow us to manage the components during a test. So, we just update our "component test library function" instead of having to update all the locators in test suite.
We also have tables that are infinite scroll and clicking on a table cell or row we would like to call our own function that automatically scrolls the table, looking for the item in the table but also waits for spinners to go away while a query is running to get the next page.
The Request
What I am requesting is a way to hook into the code generator that calls a "custom function" with the locator/element that it found. Then this custom function could do its own interrogation of the DOM using that locator/element as a starting point. If the custom function returns some 'code' then insert that code into the code generation, otherwise revert to what was originally going to be created.
Having something like this would allow teams to abstract their custom components or even use of page objects and allow more complex use of the generator for components like an infinite scroll table.
Some Limitations
Obviously, there are some things that may have to be "hand tweaked" in the generated code (like imports or adding fixtures to the test), but this would be a great way to leverage the CodeGenerator to initially build a test.
I assume this function or module would have to be an additional module passed on the command line that obeys some interface or exports a "specific" set of functions that the generator could call. Maybe it can also return a "template" to start with, t handle things like the initial imports and/or fixtures passed to the test.
This custom function would either have to generate code for all the languages or do nothing if it was a language it doesn't support.