Class FluentListAssert

    • Field Summary

      • Fields inherited from class org.assertj.core.api.AbstractAssert

        actual, info, myself, throwUnsupportedExceptionOnEquals
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.assertj.core.api.ListAssert<String> hasAttribute​(String attribute)
      Checks if at least one of the elements in the list of elements has the given property.
      FluentListAssert 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.
      FluentListAssert hasClass​(String classToFind)
      Checks if the element, or at least one element in a list of elements, has the class.
      FluentListAssert hasClasses​(String... classesToFind)
      Checks if the element, or at least one element in a list of elements, has all of the argument classes.
      FluentListAssert hasDimension​(org.openqa.selenium.Dimension dimension)
      Checks if the element, or at least one element in a list of elements, has given dimension.
      FluentListAssert hasId​(String idToFind)
      Checks if the element, or at least one element in a list of elements, has the given id
      FluentListAssert hasName​(String name)
      Checks if the element, or at least one element in a list of elements, has given name (in its 'name' attribute).
      FluentListAssert hasNotAttribute​(String attribute)
      Checks if the element doesn't have, or no element in a list of elements has, the given property.
      FluentListAssert hasNotClass​(String htmlClass)
      Checks if the element does not contain, or none of the elements in a list of elements contain the class
      FluentListAssert hasNotClasses​(String... htmlClasses)
      Checks if the element does not contain, or none of the elements in a list of elements contain any of the classes.
      FluentListAssert hasNotText​(String textToFind)
      Checks if the element does not contain, or none of the elements in a list of elements contain the text.
      FluentListSizeBuilder hasSize()
      Creates a FluentListSizeBuilder object from which further size related assertion methods may be called.
      FluentListAssert hasSize​(int expectedSize)
      Checks whether the list size is the same as the expected one in the argument.
      FluentListAssert hasTagName​(String tagName)
      Checks if the element, or at least one element in a list of elements, has given tag.
      FluentListAssert hasText​(String textToFind)
      Checks if the element, or at least one element in a list of elements, contain the text.
      FluentListAssert hasTextMatching​(String regexToBeMatched)
      Checks if the element, or at least one element in a list of elements, matches the given regex.
      FluentListAssert hasValue​(String value)
      Checks if the element, or at least one element in a list of elements has given value (in its 'value' attribute).
      FluentListAssert isEmpty()
      Checks if the list is empty.
      FluentListAssert isNotEmpty()
      Checks if the list is not empty.
      • Methods inherited from class org.assertj.core.api.AbstractAssert

        as, as, asInstanceOf, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
    • Method Detail

      • hasSize

        public FluentListAssert hasSize​(int expectedSize)
        Description copied from interface: ListStateAssert
        Checks whether the list size is the same as the expected one in the argument.

        Example:

         assertThat(elementList).hasSize(5);
         
        Specified by:
        hasSize in interface ListStateAssert
        Parameters:
        expectedSize - expected size
        Returns:
        this assertion object
      • hasSize

        public FluentListSizeBuilder hasSize()
        Description copied from interface: ListStateAssert
        Creates a FluentListSizeBuilder object from which further size related assertion methods may be called.

        This method doesn't do any assertion, only creates the new object.

        Example:

         assertThat(elementList).hasSize().greaterThanOrEqualTo(5);
         
        Specified by:
        hasSize in interface ListStateAssert
        Returns:
        a new ist size builder
      • hasText

        public FluentListAssert hasText​(String textToFind)
        Description copied from interface: FluentAssert
        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.
        Specified by:
        hasText in interface FluentAssert
        Parameters:
        textToFind - text to find
        Returns:
        this assertion object.
      • hasTextMatching

        public FluentListAssert hasTextMatching​(String regexToBeMatched)
        Description copied from interface: FluentAssert
        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$");
         
        Specified by:
        hasTextMatching in interface FluentAssert
        Parameters:
        regexToBeMatched - regex to be matched
        Returns:
        this assertion object.
      • hasNotText

        public FluentListAssert hasNotText​(String textToFind)
        Description copied from interface: FluentAssert
        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.
        Specified by:
        hasNotText in interface FluentAssert
        Parameters:
        textToFind - text to find
        Returns:
        this assertion object.
      • hasId

        public FluentListAssert hasId​(String idToFind)
        Description copied from interface: FluentAssert
        Checks if the element, or at least one element in a list of elements, has the given id

        Example:

        For a FluentWebElement it can be:

         assertThat(element).hasId("marked");
         
        which passes when the element text is equal to the argument idToFind.
        Specified by:
        hasId in interface FluentAssert
        Parameters:
        idToFind - id to find
        Returns:
        this assertion object.
      • hasClass

        public FluentListAssert hasClass​(String classToFind)
        Description copied from interface: FluentAssert
        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 argument classToFind.
        Specified by:
        hasClass in interface FluentAssert
        Parameters:
        classToFind - class to find
        Returns:
        this assertion object.
      • hasClasses

        public FluentListAssert hasClasses​(String... classesToFind)
        Description copied from interface: FluentAssert
        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 argument classesToFind.
        Specified by:
        hasClasses in interface FluentAssert
        Parameters:
        classesToFind - classes to find
        Returns:
        this assertion object.
      • hasNotClass

        public FluentListAssert hasNotClass​(String htmlClass)
        Description copied from interface: FluentAssert
        Checks if the element does not contain, or none of the elements in a list of elements contain the class

        It 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");
         
        Specified by:
        hasNotClass in interface FluentAssert
        Parameters:
        htmlClass - class to find the absence of
        Returns:
        this assertion object.
      • hasNotClasses

        public FluentListAssert hasNotClasses​(String... htmlClasses)
        Description copied from interface: FluentAssert
        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");
         
        Specified by:
        hasNotClasses in interface FluentAssert
        Parameters:
        htmlClasses - classes to find the absence of
        Returns:
        this assertion object.
      • hasValue

        public FluentListAssert hasValue​(String value)
        Description copied from interface: FluentAssert
        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.
        Specified by:
        hasValue in interface FluentAssert
        Parameters:
        value - value to find
        Returns:
        this assertion object.
      • hasName

        public FluentListAssert hasName​(String name)
        Description copied from interface: FluentAssert
        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.
        Specified by:
        hasName in interface FluentAssert
        Parameters:
        name - name to find
        Returns:
        this assertion object.
      • hasTagName

        public FluentListAssert hasTagName​(String tagName)
        Description copied from interface: FluentAssert
        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.
        Specified by:
        hasTagName in interface FluentAssert
        Parameters:
        tagName - tag name to find
        Returns:
        this assertion object.
      • hasDimension

        public FluentListAssert hasDimension​(org.openqa.selenium.Dimension dimension)
        Description copied from interface: FluentAssert
        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.
        Specified by:
        hasDimension in interface FluentAssert
        Parameters:
        dimension - dimension to find
        Returns:
        this assertion object.
      • hasAttributeValue

        public FluentListAssert hasAttributeValue​(String attribute,
                                                  String value)
        Description copied from interface: FluentAssert
        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.com");
         
        Specified by:
        hasAttributeValue in interface FluentAssert
        Parameters:
        attribute - attribute to find
        value - property value to match with actual
        Returns:
        this assertion object.
      • hasAttribute

        public org.assertj.core.api.ListAssert<String> hasAttribute​(String attribute)
        Description copied from interface: ListAttributeAssert
        Checks if at least one of the elements in the list of elements has the given property.

        It allows users to do not just presence validation but to apply chained List assertions to further validate the attribute values.

        Examples:

        Validating the presence of an attribute on a FluentList:

         assertThat(fluentList).hasAttribute("class");
         

        Validating both the presence of an attribute on a fluent list, and the value of that attribute:

         assertThat(element).hasAttribute("class").containsAnyOf("some-class", "other-class");
         
        Specified by:
        hasAttribute in interface AttributeAssert<org.assertj.core.api.ListAssert<String>>
        Specified by:
        hasAttribute in interface ListAttributeAssert
        Parameters:
        attribute - the attribute to find
        Returns:
        a new ListAssert object with the actual attribute values
      • hasNotAttribute

        public FluentListAssert hasNotAttribute​(String attribute)
        Description copied from interface: AttributeAssert
        Checks if the element doesn't have, or no element in a list of elements has, the given property.
        Specified by:
        hasNotAttribute in interface AttributeAssert<org.assertj.core.api.ListAssert<String>>
        Parameters:
        attribute - attribute to find the absence of
        Returns:
        this assertion object.