Interface FluentAssert
- All Known Implementing Classes:
FluentListAssert
,FluentWebElementAssert
-
Method Summary
Modifier and TypeMethodDescriptionorg.assertj.core.api.AbstractAssert
hasAttributeValue
(String attribute, String value) Checks if the element, or at least one element in a list of elements, has property with the exact given value.org.assertj.core.api.AbstractAssert
Checks if the element, or at least one element in a list of elements, has the class.org.assertj.core.api.AbstractAssert
hasClasses
(String... classesToFind) Checks if the element, or at least one element in a list of elements, has all of the argument classes.org.assertj.core.api.AbstractAssert
hasDimension
(org.openqa.selenium.Dimension dimension) Checks if the element, or at least one element in a list of elements, has given dimension.org.assertj.core.api.AbstractAssert
Checks if the element, or at least one element in a list of elements, has the given idorg.assertj.core.api.AbstractAssert
Checks if the element, or at least one element in a list of elements, has given name (in its 'name' attribute).org.assertj.core.api.AbstractAssert
hasNotClass
(String htmlClass) Checks if the element does not contain, or none of the elements in a list of elements contain the classorg.assertj.core.api.AbstractAssert
hasNotClasses
(String... classesToFind) Checks if the element does not contain, or none of the elements in a list of elements contain any of the classes.org.assertj.core.api.AbstractAssert
hasNotText
(String textToFind) Checks if the element does not contain, or none of the elements in a list of elements contain the text.org.assertj.core.api.AbstractAssert
hasNotTextContaining
(String textToFind) Checks if the element does not contain, or none of the elements in a list of elements contain the text.org.assertj.core.api.AbstractAssert
hasTagName
(String tagName) Checks if the element, or at least one element in a list of elements, has given tag.org.assertj.core.api.AbstractAssert
Checks if the element, or at least one element in a list of elements, contain the text.org.assertj.core.api.AbstractAssert
hasTextContaining
(String text) Checks if the element, or at least one element in a list of elements, contain the text.org.assertj.core.api.AbstractAssert
hasTextMatching
(String regexToBeMatched) Checks if the element, or at least one element in a list of elements, matches the given regex.org.assertj.core.api.AbstractAssert
Checks if the element, or at least one element in a list of elements has given value (in its 'value' attribute).
-
Method Details
-
hasText
Checks if the element, or at least one element in a list of elements, contain the text.Example:
For a
FluentWebElement
it can be:assertThat(element).hasText("magnificent");
which passes when the element contains (but is not necessarily exactly equal to) the argument text.NOTE: currently both this method and
hasTextContaining(String)
validate text containment. If you want to validate containment please usehasTextContaining(String)
, as this method will be updated in a future release to validate equality of text(s).- Parameters:
textToFind
- text to find- Returns:
this
assertion object.
-
hasTextContaining
Checks if the element, or at least one element in a list of elements, contain the text.Example:
For a
FluentWebElement
it can be:assertThat(element).hasTextContaining("magnificent");
which passes when the element contains (but is not necessarily exactly equal to) the argument text.NOTE: currently both
hasText(String)
and this method validate text containment. If you want to validate containment please use this method, ashasText(String)
will be updated in a future release to validate equality of text(s).- Parameters:
text
- text to find- Returns:
this
assertion object.
-
hasTextMatching
Checks if the element, or at least one element in a list of elements, matches the given regex.Example:
For a
FluentWebElement
it can be:assertThat(element).hasTextMatching(".*magnificent$");
- Parameters:
regexToBeMatched
- regex to be matched- Returns:
this
assertion object.
-
hasNotText
Checks if the element does not contain, or none of the elements in a list of elements contain the text.Example:
For a
FluentWebElement
it can be:assertThat(element).hasNotText("magnificent");
which passes when the element text doesn't contains (and not when it is not equal to) to the argument text.NOTE: currently both this method and
hasNotTextContaining(String)
validate text containment. If you want to validate containment please usehasNotTextContaining(String)
, as this method will be updated in a future release to validate equality of text(s).- Parameters:
textToFind
- text to find- Returns:
this
assertion object.
-
hasNotTextContaining
Checks if the element does not contain, or none of the elements in a list of elements contain the text.Example:
For a
FluentWebElement
it can be:assertThat(element).hasNotText("magnificent");
which passes when the element text doesn't contains (and not when it is not equal to) to the argument text.NOTE: currently both
hasNotText(String)
and this method validate text containment. If you want to validate containment please use this method, ashasNotText(String)
will be updated in a future release to validate equality of text(s).- Parameters:
textToFind
- text to find- Returns:
this
assertion object.
-
hasId
Checks if the element, or at least one element in a list of elements, has the given idExample:
For a
FluentWebElement
it can be:assertThat(element).hasId("marked");
which passes when the element text is equal to the argumentidToFind
.- Parameters:
idToFind
- id to find- Returns:
this
assertion object.
-
hasClass
Checks if the element, or at least one element in a list of elements, has the class.Example:
For a
FluentWebElement
it can be:assertThat(element).hasClass("marked");
which passes when the element class attribute (handled as a list of class values) contains the argumentclassToFind
.- Parameters:
classToFind
- class to find- Returns:
this
assertion object.
-
hasNotClass
Checks if the element does not contain, or none of the elements in a list of elements contain the classIt passes assertion both when the class attribute is present but doesn't contain the argument class, and when the class attribute is not present at all.
Example:
For a
FluentWebElement
it can be:assertThat(element).hasNotClass("marked");
- Parameters:
htmlClass
- class to find the absence of- Returns:
this
assertion object.
-
hasClasses
Checks if the element, or at least one element in a list of elements, has all of the argument classes.Example:
For a
FluentWebElement
it can be:assertThat(element).hasClasses("marked", "as", "great");
which passes when the element class attribute (handled as a list of class values) contains all of the argumentclassesToFind
.- Parameters:
classesToFind
- classes to find- Returns:
this
assertion object.
-
hasNotClasses
Checks if the element does not contain, or none of the elements in a list of elements contain any of the classes.Example:
For a
FluentWebElement
it can be:assertThat(element).hasNotClasses("marked", "as", "great");
- Parameters:
classesToFind
- classes to find the absence of- Returns:
this
assertion object.
-
hasValue
Checks if the element, or at least one element in a list of elements has given value (in its 'value' attribute).Example:
For a
FluentWebElement
it can be:assertThat(element).hasValue("John Smith");
which passes when the element's value is equal to the argument value.- Parameters:
value
- value to find- Returns:
this
assertion object.
-
hasName
Checks if the element, or at least one element in a list of elements, has given name (in its 'name' attribute).Example:
For a
FluentWebElement
it can be:assertThat(element).hasName("John Smith");
which passes when the element's value is equal to the argument name.- Parameters:
name
- name to find- Returns:
this
assertion object.
-
hasTagName
Checks if the element, or at least one element in a list of elements, has given tag.Example:
For a
FluentWebElement
it can be:assertThat(element).hasTagName("div");
which passes when the element's value is equal to the argument tag name.- Parameters:
tagName
- tag name to find- Returns:
this
assertion object.
-
hasAttributeValue
Checks if the element, or at least one element in a list of elements, has property with the exact given value.Example:
For a
FluentWebElement
it can be:assertThat(element).hasAttributeValue("href", "https://fluentlenium.io");
- Parameters:
attribute
- attribute to findvalue
- property value to match with actual- Returns:
this
assertion object.
-
hasDimension
org.assertj.core.api.AbstractAssert hasDimension(org.openqa.selenium.Dimension dimension) Checks if the element, or at least one element in a list of elements, has given dimension.Example:
For a
FluentWebElement
it can be:assertThat(element).hasDimension(fluentWebElement.getDimension());
which passes when the element's dimension is equal to the argument dimension.- Parameters:
dimension
- dimension to find- Returns:
this
assertion object.
-