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

collection.should_each(have.text('foo')) vs collection.should(have.text('foo').each) #277

Closed
yashaka opened this issue Jan 10, 2021 · 0 comments

Comments

@yashaka
Copy link
Owner

yashaka commented Jan 10, 2021

Currently selene supports

collection = browser.all('.item')
collection.should(have.text('foo'))

it becomes even more obvious what it means when having this style:

browser.all('.item').should(have.text('foo'))

It asserts that all items (collection of elements found by '.item' selector)

  • have same text - foo

So, it kind of similar (but more powerful):

for item in browser.all('.item'):
    item.should(have.text('foo'))

This feature for collection's should to accept element conditions too, was added in Selene 2.0, because I found it's extremely readable and obvious from the context of "native english speaker".

But it happened that people often misuse the following cases:

  • browser.all('.item').should(have.text('foo'))
  • browser.all('.item').should(have.texts('foo'))
    which a completely different

Even more often it happens when the ss style is used:

  • ss('.item').should(have.text('foo'))
  • ss('.item').should(have.texts('foo'))

So despite of the fact that this: browser.all('.item').should(have.text('foo')) – is the pure beauty to my taste:) – now I think we have to depracate this style... and don't allow for collection's should to accept element conditions...

This is even more becomes actual, because now I am not totally shure that the name browser.all is a perfect name... I realaized this when found that there are some usefull methods in collection that might interfere by meaning with this browser.all... Let's see how will it go further... But for now it seems like the style of selene 1.0 to have separate collection.should_each(element_condition) style was better (this should_each method is marked as deprecated for now).

So probably, at least we can come back to .should_each... Or... what about this style: collection.should(have.text('foo').each) ? Maybe it less readable, but then implementation of should method is simpler... Many things become more KISS inside Selene, making it easier to support and maintain....

yashaka added a commit that referenced this issue Sep 26, 2022
+ deprecate `collection.should(element_condition)` and `collection.should_each(element_condition)`
+ bump version to 2.0.0b12 & prepare for release
github-actions bot added a commit that referenced this issue Sep 26, 2022
+ deprecate `collection.should(element_condition)` and `collection.should_each(element_condition)`
+ bump version to 2.0.0b12 & prepare for release
@yashaka yashaka closed this as completed Sep 26, 2022
Selene 2.0.0 stable release automation moved this from To do to Done Sep 26, 2022
yashaka added a commit that referenced this issue Sep 26, 2022
+ ... and ability to pass element_condition to `collection.should(HERE)`
  -  Use instead: `collection.should(element_condition.each)`
+ bump version to 2.0.0b13
+ update README.md for 2.0.0b12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant