-
Notifications
You must be signed in to change notification settings - Fork 562
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
Method $.shouldHave(text)
should verify the whole text (not a substring)
#1780
Comments
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
In the beginning, one might indeed think that Although, the option with a configuration is backwards compatible, having yet another configuration is not the best solution, IMO. If the decision would be to switch the |
I would go with partialText() and exactText() and deprecate text(). Maybe those should also have an optional flag to make it case sensitive? Changing text() to check the exact text is a big breaking change, in my opinion. |
# Conflicts: # src/main/java/com/codeborne/selenide/conditions/Text.java # statics/src/test/java/integration/ElementTextTest.java # statics/src/test/java/integration/SelectsTest.java
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
* "#text-area" is automatically filled by JS at the same time * it's better to use another text area which is always empty.
* "#text-area" is automatically filled by JS at the same time * it's better to use another text area which is always empty.
... to keep backward compatibility. Let's change it to FULL_TEXT in a next major release 7.0.0
@cocorossello Sure, it's a breaking change. I suggest to make it configurable: Configuration.textCheck = PARTIAL_TEXT; // current default
Configuration.textCheck = FULL_TEXT; // the "new way". We could make |
+ fix existing integration tests that assumed that `$.shouldHave(text)` checks a substring
* "#text-area" is automatically filled by JS at the same time * it's better to use another text area which is always empty.
... to keep backward compatibility. Let's change it to FULL_TEXT in a next major release 7.0.0
@asolntsev do you have any plans or thoughts on the |
@plagov Yes, when |
@asolntsev has this happened? i don't see it in the 7.0 release notes. |
Is there a partial variant of |
Hm... Good point! But no, FULL-TEXT was not made the default in Selenide 7.0.0 I am still afraid that most users hasn't enabled this flag, and this change would trigger too big hassle.. What do you think? |
hm, we had to migrate a few things anyways in the 7.0 major update (e.g.
|
To be honest, I forgot about FULL_TEXT when released 7.0.0. |
The problem
Current behaviour of
$.shouldHave(text())
is misleading. People might think it verifies the whole text, but it actually verifies only a substring.For example
The test:
$.shouldHave(text("error"));
may be green even if html has text<div>NO errors</div>
which has the opposite meaning. This behaviour can cause false positive tests.Historical reasons
Many years ago I decided to check a substring in order to ignore spaces, tabs, newlines etc. Now it seems it was not really needed because the condition
text
already implements this logic inside.For backward compatibility
I suggest to
$.shouldHave(text())
to verify the whole textConfiguration.textCheck = FULL_TEXT | PARTIAL_TEXT;
which allows users to restore the previous behaviour in case if they get a lot of failing tests.Tell us about your environment
The text was updated successfully, but these errors were encountered: