selene icon indicating copy to clipboard operation
selene copied to clipboard

Collection.matching(be.present) returns True if empty

Open SanKolts opened this issue 2 years ago • 1 comments

Following code

browser.all('.some-random-and-for-sure-is-not-presented-in-a-dom-class').matching(be.present)

returns True but it should be False

This leads to situations when browser.all('.some-random-and-for-sure-is-not-presented-in-a-dom-class').should(be.present) passes and browser.all('.some-random-and-for-sure-is-not-presented-in-a-dom-class').should(be.absent) fails.

SanKolts avatar Jan 02 '23 11:01 SanKolts

Hm... That's an interesting case...

Actually be.present is not a "collection condition", it is not supposed to be called on browser.all(selector).should(HERE)

You even should get a warning in IDE like PyCharm.

To achieve what you want you are supposed to use have.size*

But the case is yet interesting... Maybe we should consider allowing users to have conditions that can be called both on single element and collection of elements. Just... This is pretty complicated thing to analyze and investigate all edge cases. For this definitely not a bug... Yet I'll think what to do to make API even more friendly and natural, yet powerful and straightforward.

On Mon, Jan 2, 2023, 13:24 SanKolts @.***> wrote:

Following code

browser.all('.some-random-and-for-sure-is-not-presented-in-a-dom-class').matching(be.present)

returns

True

But it should be

False

This leads to situations when

browser.all('.some-random-and-for-sure-is-not-presented-in-a-dom-class').should(be.present) passes and

browser.all('.some-random-and-for-sure-is-not-presented-in-a-dom-class').should(be.absent) fails.

— Reply to this email directly, view it on GitHub https://github.com/yashaka/selene/issues/465, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO6ZHQTIGMZYIVIDWNWR5TWQK3HHANCNFSM6AAAAAATOXPIHI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

yashaka avatar Jan 02 '23 13:01 yashaka