-
Notifications
You must be signed in to change notification settings - Fork 22
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
first() is fundamentally broken #1729
Comments
Yup, |
I have used |
Deprecation for removal is the only warning developer understand 🙂 |
However, I don't believe it is appropriate to deprecate a convenience method just because its use has been abused due to previous lack of an appropriate method. For instance, although I would categorize the situation more as "Legacy use of BTW, there is also a companion |
Proposed change:
|
The expression
$(ButtonWrapper.class).first()
should fundamentally not be used in a test: it promotes creation of flaky tests. If there are multiple Buttons on the web page, TestBench selects an arbitrary one and then the test may (or may not) fail later on, after the button is clicked and the outcome is something else than the test intended.Instead, there should be a
get()
function which asserts that there's exactly one Button, failing if there are multiple matching Buttons. That's exactly what Playwright is doing: at https://playwright.dev/java/docs/writing-tests thepage.getByRole(xyz)
will fail if there are multiple matching elements.first()
should be deprecated and replaced byget()
(which selects one), orget(int)
which returns a list of elements and asserts that it's of that particular size.The text was updated successfully, but these errors were encountered: