-
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
feat!: provide additional selectors to ElementQuery #1774
Conversation
I want to point out one thing I changed in the implementation of Up until now there was no
to mirror how What I want to make sure of is that this is not breaking anything in valid Vaadin light/shadow DOM HTML. It would be simple enough to switch However, this could potentially break some customers' tests, but that might be a valuable discovery for them—that they have duplicate ids. I have added a note to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job and great that you updated the README!
However, once all the comments will be addressed, I propose to squash the change into two separated commits, one for the README update and the other for the code changes.
vaadin-testbench-core-junit5/src/main/java/com/vaadin/testbench/AbstractBrowserTestBase.java
Outdated
Show resolved
Hide resolved
vaadin-testbench-integration-tests-junit5/src/test/java/com/vaadin/tests/ElementQueryIT.java
Show resolved
Hide resolved
vaadin-testbench-integration-tests-junit5/src/test/java/com/vaadin/tests/ElementQueryIT.java
Outdated
Show resolved
Hide resolved
vaadin-testbench-shared/src/main/java/com/vaadin/testbench/ElementQuery.java
Show resolved
Hide resolved
vaadin-testbench-shared/src/main/java/com/vaadin/testbench/ElementQuery.java
Show resolved
Hide resolved
vaadin-testbench-shared/src/main/java/com/vaadin/testbench/ElementQuery.java
Show resolved
Hide resolved
vaadin-testbench-shared/src/main/java/com/vaadin/testbench/ElementQuery.java
Outdated
Show resolved
Hide resolved
vaadin-testbench-shared/src/main/java/com/vaadin/testbench/ElementQuery.java
Show resolved
Hide resolved
First of all, I agree that fail fast if IDs are duplicated is an expected behaviour for I recommend to update |
Yes, this commenting has already been done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I would just squash into two commits, one for README and the other for Java changes before merging into main
e4d395d
to
9b8bc4b
Compare
@mshabarov it looks like "Rebase and merge" is not enabled on this repo. |
) In contrast to ComponentQuerys of unit testing TestBench, ElementQuerys in E2E testing TestBench have (up until now) only provided attribute-based selector methods. This was expanded upon in PR #1774 to provide selector methods for common attributes, such as those for class names, theme, and id. This PR adds condition-based selector methods to ElementQuery to mirror and expand upon those of ComponentQuery. Namely: withCondition withPropertyValue[Containing] withLabel[Containing] withPlaceholder[Containing] withCaption[Containing] withText[Containing] Elements having their labels in their text (such as buttons) must implement a new, method-less interface HasLabelAsText in their element tester (such as NativeButtonElement for the NativeButton component and ButtonElement for the Button component) in order for the withCaption[Containing] selectors to work for them. This PR brings the E2E testing selectors up to par with the unit testing selectors. The only one missing is withValue. Fixes #1183
Description
Fixes #662 & #1183 (partially)
Adds some selectors to
ElementQuery
(integration testing) to parallel those provided byComponentQuery
(unit testing). The selectors added in this change are limited to the ones that are "attribute" based.ElementQuery<T> withAttribute(String attribute)
ElementQuery<T> withAttribute(String attribute, String value)
ElementQuery<T> withAttributeContaining(String attribute, String value)
ElementQuery<T> withoutAttribute(String attribute)
ElementQuery<T> withoutAttribute(String attribute, String value)
ElementQuery<T> withoutAttributeContaining(String attribute, String value)
ElementQuery<T> withId(String id)
ElementQuery<T> withClassName(String... className)
ElementQuery<T> withoutClassName(String... className)
ElementQuery<T> withTheme(String theme)
ElementQuery<T> withoutTheme(String theme)
T single()
In addition, three existing selectors that did not match the naming convention of the
ComponentQuery
(unit testing) selectors were deprecated in lieu of the new ones.ElementQuery<T> hasAttribute(String name)
→ElementQuery<T> withAttribute(String attribute)
ElementQuery<T> attribute(String name, String value)
→ElementQuery<T> withAttribute(String attribute, String value)
ElementQuery<T> attributeContains(String name, String token)
→ElementQuery<T> withAttributeContaining(String attribute, String value)
Added both unit and integration tests for the new selectors and for others that were missing.
Updated the README.md file with instructions for configuring and running integration tests in the IntelliJ IDEA IDE.
Type of change
Checklist
Additional for
Feature
type of changeAdditional missing selectors are currently being considered, such as:
ElementQuery<T> withCondition(Predicate<T> condition)
ElementQuery<T> withCaption(String caption)
ElementQuery<T> withCaptionContaining(String text)
ElementQuery<T> withText(String text)
ElementQuery<T> withTextContaining(String text)
<V> ElementQuery<T> withValue(V value)