My code:
private static final String EMPTY_STRING = "";
SelenideElement Element = $(byClassName("phone-box"))
Element.shouldNotHave(text(EMPTY_STRING));
=> Test failed with message:
Element should not have text '' {By.className: phone-box}
Element: '+7 499 955-56-58'
!!!!BUT!!!!
Operator Assert.assertFalse(Element.text().equals(EMPTY_STRING)); is working fine.
Hi @AlexMMelnikov
could you provide simple html page to reproduce problem?
Hello. Yes, sure - https://aurora-tech.ru/
sholdNotBe(empty) work well
@AlexMMelnikov
I guess it isn't Selenide issue.
Explanation:
Hope I helped you.
@AlexMMelnikov Exactly. Methods $.shouldHave(text(...)) and $.shouldNotHave(text(...)) mean substring. Both methods are nonsence with empty string parameter.
(Probably they could throw an exception (or at least write warning) when empty parameter is given.)
What you actually need is $.sholdNotBe(empty)