Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector scopes #20

Open
inca opened this issue Jun 30, 2015 · 4 comments
Open

Selector scopes #20

inca opened this issue Jun 30, 2015 · 4 comments

Comments

@inca
Copy link
Contributor

inca commented Jun 30, 2015

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:

  1. long selectors (real example: '[ui-view="props"] [ng-repeat^="prop in"]:last-child [ui-sref^="product.prop"]')
  2. 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

@puzrin
Copy link
Member

puzrin commented Jun 30, 2015

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

@inca
Copy link
Contributor Author

inca commented Jun 30, 2015

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!

@inca inca closed this as completed Jun 30, 2015
@puzrin
Copy link
Member

puzrin commented Jun 30, 2015

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.

@inca
Copy link
Contributor Author

inca commented Jun 30, 2015

Thanks, reopening then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants