Selector scopes
Opened this issue · 4 comments
This topic is more of a discussion rather than a call for action.
I am seeking solutions for two minor problems I've faced recently writing e2e tests for a medium-sized SPA:
- long selectors (real example:
'[ui-view="props"] [ng-repeat^="prop in"]:last-child [ui-sref^="product.prop"]'
) - mass repetition of selector prefixes (the
[ui-view="props"]
denotes the context where we test and it is repeated a lot)
Both problems could be addressed by introducing a concept of "current scope": by default it is unset (which means we will search in document
), but if you do browser.scope('[ui-view="props"]')
then all subsequent selections will occur within that element.
Asking you to actually do that would be too insolent since it would require revisiting every method and, more importantly, covering all that with a separate test suite. Therefore, I'm asking for an advice, maybe you've come across similar problems and already have a solution.
TIA
We have simple tests, no such problem. May be lazy evaluated functions will help? Instead of selector string you can use helper call to add prefix. Something like pref(my_string)
.
A bit shitty, but can help
Thanks for prompt response, Vitaly. I used to generate selectors in Node to save some keystrokes, which certainly helps, but doesn't yield too much readability — having 3 different functions per test case to generate selectors really looks a bit messy.
However, I guess I'll stick with this approach.
Thanks again for your help!
As far as i remember, we have prefix for .open()
to not write boring http://localhost:3000
in each address. From this point of view, your example looks convincing.
In theory selector prefixes are possible, at least at global level. We can keep issue open with very low priority to investigate sometime in far future.
Thanks, reopening then.