Class FluentListAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF, ACTUAL>
io.fluentlenium.assertj.custom.FluentListAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<FluentListAssert, FluentList>, org.assertj.core.api.Descriptable<FluentListAssert>, org.assertj.core.api.ExtensionPoints<FluentListAssert, FluentList>, AttributeAssert<org.assertj.core.api.ListAssert<String>>, FluentAssert, ListAttributeAssert, ListStateAssert

public class FluentListAssert extends org.assertj.core.api.AbstractAssert<SELF,ACTUAL> implements ListStateAssert, ListAttributeAssert
Default implementation for FluentList assertions.
  • Field Summary

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

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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.
    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.
    hasClass (String classToFind)
    Checks if the element, or at least one element in a list of elements, has the class.
    hasClasses (String... classesToFind)
    Checks if the element, or at least one element in a list of elements, has all of the argument classes.
    hasDimension (org.openqa.selenium.Dimension dimension)
    Checks if the element, or at least one element in a list of elements, has given dimension.
    hasId (String idToFind)
    Checks if the element, or at least one element in a list of elements, has the given id
    hasName (String name)
    Checks if the element, or at least one element in a list of elements, has given name (in its 'name' attribute).
    hasNotAttribute (String attribute)
    Checks if the element doesn't have, or no element in a list of elements has, the given property.
    hasNotClass (String htmlClass)
    Checks if the element does not contain, or none of the elements in a list of elements contain the class
    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.
    hasNotText (String textToFind)
    Checks if the element does not contain, or none of the elements in a list of elements contain the text.
    Checks if the element does not contain, or none of the elements in a list of elements contain the text.
    Creates a FluentListSizeBuilder object from which further size related assertion methods may be called.
    hasSize (int expectedSize)
    Checks whether the list size is the same as the expected one in the argument.
    hasTagName (String tagName)
    Checks if the element, or at least one element in a list of elements, has given tag.
    hasText (String textToFind)
    Checks if the element, or at least one element in a list of elements, contain the text.
    hasTextContaining (String textToFind)
    Checks if the element, or at least one element in a list of elements, contain the text.
    hasTextMatching (String regexToBeMatched)
    Checks if the element, or at least one element in a list of elements, matches the given regex.
    hasValue (String value)
    Checks if the element, or at least one element in a list of elements has given value (in its 'value' attribute).
    Checks if the list is empty.
    Checks if the list is not empty.

    Methods inherited from class org.assertj.core.api.AbstractAssert

    areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, as, as, describedAs
  • Constructor Details

  • Method Details

    • isEmpty

      public FluentListAssert isEmpty()
      Description copied from interface: ListStateAssert
      Checks if the list is empty.

      Example:

       assertThat(elementList).isEmpty();
       
      Specified by:
      isEmpty in interface ListStateAssert
      Returns:
      this assertion object
    • isNotEmpty

      public FluentListAssert isNotEmpty()
      Description copied from interface: ListStateAssert
      Checks if the list is not empty.

      Example:

       assertThat(elementList).isNotEmpty();
       
      Specified by:
      isNotEmpty in interface ListStateAssert
      Returns:
      this assertion object
    • 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.

      NOTE: currently both this method and FluentAssert.hasTextContaining(String) validate text containment. If you want to validate containment please use FluentAssert.hasTextContaining(String), as this method will be updated in a future release to validate equality of text(s).

      Specified by:
      hasText in interface FluentAssert
      Parameters:
      textToFind - text to find
      Returns:
      this assertion object.
    • hasTextContaining

      public FluentListAssert hasTextContaining (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).hasTextContaining("magnificent");
       
      which passes when the element contains (but is not necessarily exactly equal to) the argument text.

      NOTE: currently both FluentAssert.hasText(String) and this method validate text containment. If you want to validate containment please use this method, as FluentAssert.hasText(String) will be updated in a future release to validate equality of text(s).

      Specified by:
      hasTextContaining 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.

      NOTE: currently both this method and FluentAssert.hasNotTextContaining(String) validate text containment. If you want to validate containment please use FluentAssert.hasNotTextContaining(String), as this method will be updated in a future release to validate equality of text(s).

      Specified by:
      hasNotText in interface FluentAssert
      Parameters:
      textToFind - text to find
      Returns:
      this assertion object.
    • hasNotTextContaining

      public FluentListAssert hasNotTextContaining (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.

      NOTE: currently both FluentAssert.hasNotText(String) and this method validate text containment. If you want to validate containment please use this method, as FluentAssert.hasNotText(String) will be updated in a future release to validate equality of text(s).

      Specified by:
      hasNotTextContaining 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.io");
       
      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.