-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
use ... as placeholder in have.texts like collection conditions #528
Labels
Comments
yashaka
added a commit
that referenced
this issue
May 23, 2024
+ texts like conditions now accepts int and floats as text item with a TODO: implement same for other text conditions + some commented not needed anymore code was left to temporary log in commit some decisions made
github-actions bot
added a commit
that referenced
this issue
May 23, 2024
+ texts like conditions now accepts int and floats as text item with a TODO: implement same for other text conditions + some commented not needed anymore code was left to temporary log in commit some decisions made
List of conditions added (still marked as experimental with
Where:
Warning:
Examples of usage: from selene import browser, have
...
# GivenPage(browser.driver).opened_with_body(
# '''
# <ul>Hello:
# <li>1) One!!!</li>
# <li>2) Two!!!</li>
# <li>3) Three!!!</li>
# <li>4) Four!!!</li>
# <li>5) Five!!!</li>
# </ul>
# '''
# )
browser.all('li').should(have._exact_texts_like(
'1) One!!!', '2) Two!!!', ..., ..., ... # = exactly one
))
browser.all('li').should(have._texts_like(
'\d\) One!+', '\d.*', ..., ..., ...
).with_regex)
browser.all('li').should(have._texts_like(
'?) One*', '?) Two*', ..., ..., ...
).with_wildcards)
browser.all('li').should(have._texts_like(
'_) One**', '_) Two*', ..., ..., ...
).where_wildcards(zero_or_more='**', exactly_one='_'))
browser.all('li').should(have._texts_like(
'One', 'Two', ..., ..., ... # matches each text by contains
)) # kind of "with implicit * wildcards" in the beginning and the end of each text
browser.all('li').should(have._texts_like(
..., ..., ..., 'Four', 'Five'
))
browser.all('li').should(have._texts_like(
'One', ..., ..., 'Four', ... # = exactly one
))
browser.all('li').should(have._texts_like(
'One', 'Two', (..., ) # = one or more
))
browser.all('li').should(have._texts_like(
[(..., )], 'One', 'Two', [(..., )] # = ZERO or more ;)
))
browser.all('li').should(have._texts_like(
[...], 'One', 'Two', 'Three', 'Four', [...] # = zero or ONE ;)
))
# If you don't need so much "globs"...
# (here goes, actually, the 💡RECOMMENDED💡 way to use it in most cases...
# to keep things simpler for easier support and more explicit for readability)
# – you can use the simplest glob item with explicitly customized meaning:
browser.all('li').should(have._exact_texts_like(
..., 'One', 'Two', ... # = zero OR MORE
).where(zero_or_more=...)) # – because the ... meaning was overridden
# Same works for other conditions that end with `_like`
browser.all('li').should(have._exact_texts_like(
..., '1) One!!!', '2) Two!!!', ...
).where(zero_or_more=...)) |
yashaka
added a commit
that referenced
this issue
May 24, 2024
+ [#528] DOCS: docstrings for have.*_like collection conditions and also more verbose parameter names + Fix misleading absence of waiting in slicing behavior
github-actions bot
added a commit
that referenced
this issue
May 24, 2024
+ [#528] DOCS: docstrings for have.*_like collection conditions and also more verbose parameter names + Fix misleading absence of waiting in slicing behavior
Here are the critique of previous globs:
So, why not define default list globs as:
Examples of usage: from selene import browser, have
...
# GivenPage(browser.driver).opened_with_body(
# '''
# <ul>Hello:
# <li>1) One!!!</li>
# <li>2) Two!!!</li>
# <li>3) Three!!!</li>
# <li>4) Four!!!</li>
# <li>5) Five!!!</li>
# </ul>
# '''
# )
browser.all('li').should(have._exact_texts_like(
'1) One!!!', '2) Two!!!', {...}, {...}, {...} # = exactly one
))
browser.all('li').should(have._texts_like(
'\d\) One!+', '\d.*', {...}, {...}, {...}
).with_regex)
browser.all('li').should(have._texts_like(
'?) One*', '?) Two*', {...}, {...}, {...}
).with_wildcards)
browser.all('li').should(have._texts_like(
'_) One**', '_) Two*', {...}, {...}, {...}
).where_wildcards(zero_or_more='**', exactly_one='_'))
browser.all('li').should(have._texts_like(
'One', 'Two', {...}, {...}, {...} # matches each text by contains
)) # kind of "with implicit * wildcards" in the beginning and the end of each text
browser.all('li').should(have._texts_like(
{...}, {...}, {...}, 'Four', 'Five'
))
browser.all('li').should(have._texts_like(
'One', {...}, {...}, 'Four', {...} # = exactly one
))
browser.all('li').should(have._texts_like(
'One', 'Two', ... # = one or more
))
browser.all('li').should(have._texts_like(
[...], 'One', 'Two', [...] # = ZERO or more ;)
))
browser.all('li').should(have._texts_like(
[{...}], 'One', 'Two', 'Three', 'Four', [{...}] # = zero or ONE ;)
))
# If you don't need so much "globs"...
# (here goes, actually, the 💡RECOMMENDED💡 way to use it in most cases...
# to keep things simpler for easier support and more explicit for readability)
# – you can use the simplest glob item with explicitly customized meaning:
browser.all('li').should(have._exact_texts_like(
..., 'One', 'Two', ... # = one OR MORE
).where(zero_or_more=...)) # – because the ... meaning was overridden
# Same works for other conditions that end with `_like`
browser.all('li').should(have._exact_texts_like(
..., '1) One!!!', '2) Two!!!', ...
).where(zero_or_more=...)) |
yashaka
added a commit
that referenced
this issue
Jun 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something like:
The text was updated successfully, but these errors were encountered: