Class FluentWebElementAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF, ACTUAL>
io.fluentlenium.assertj.custom.FluentWebElementAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<FluentWebElementAssert, FluentWebElement>, org.assertj.core.api.Descriptable<FluentWebElementAssert>, org.assertj.core.api.ExtensionPoints<FluentWebElementAssert, FluentWebElement>, AttributeAssert<org.assertj.core.api.AbstractStringAssert>, ElementAttributeAssert, ElementStateAssert, FluentAssert

public class FluentWebElementAssert extends org.assertj.core.api.AbstractAssert<SELF,ACTUAL> implements ElementStateAssert, ElementAttributeAssert
Default implementation for FluentWebElement assertions.
  • Constructor Details

    • FluentWebElementAssert

      public FluentWebElementAssert (FluentWebElement actual)
  • Method Details

    • isEnabled

      public FluentWebElementAssert isEnabled()
      Description copied from interface: ElementStateAssert
      Checks if the element is enabled.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isEnabled();
       
      Specified by:
      isEnabled in interface ElementStateAssert
      Returns:
      this assertion object.
    • isNotEnabled

      public FluentWebElementAssert isNotEnabled()
      Description copied from interface: ElementStateAssert
      Checks if the element is not enabled.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isNotEnabled();
       
      Specified by:
      isNotEnabled in interface ElementStateAssert
      Returns:
      this assertion object.
    • isDisplayed

      public FluentWebElementAssert isDisplayed()
      Description copied from interface: ElementStateAssert
      Checks if the element is displayed.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isDisplayed();
       
      Specified by:
      isDisplayed in interface ElementStateAssert
      Returns:
      this assertion object.
    • isNotDisplayed

      public FluentWebElementAssert isNotDisplayed()
      Description copied from interface: ElementStateAssert
      Checks if the element is not displayed.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isNotDisplayed();
       
      Specified by:
      isNotDisplayed in interface ElementStateAssert
      Returns:
      this assertion object.
    • isSelected

      public FluentWebElementAssert isSelected()
      Description copied from interface: ElementStateAssert
      Checks if the element is selected.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isSelected();
       
      Specified by:
      isSelected in interface ElementStateAssert
      Returns:
      this assertion object.
    • isNotSelected

      public FluentWebElementAssert isNotSelected()
      Description copied from interface: ElementStateAssert
      Checks if the element is not selected.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isNotSelected();
       
      Specified by:
      isNotSelected in interface ElementStateAssert
      Returns:
      this assertion object.
    • isClickable

      public FluentWebElementAssert isClickable()
      Description copied from interface: ElementStateAssert
      Checks if the element is clickable.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isClickable();
       
      Specified by:
      isClickable in interface ElementStateAssert
      Returns:
      this assertion object.
    • isNotClickable

      public FluentWebElementAssert isNotClickable()
      Description copied from interface: ElementStateAssert
      Checks if the element is not clickable.

      This method also has a preceding validation for the presence of the element, which fails this assertion method if it would fail.

      Example:

       assertThat(element).isNotClickable();
       
      Specified by:
      isNotClickable in interface ElementStateAssert
      Returns:
      this assertion object.
    • isPresent

      public FluentWebElementAssert isPresent()
      Description copied from interface: ElementStateAssert
      Checks if the element is present.

      Example:

       assertThat(element).isPresent();
       
      Specified by:
      isPresent in interface ElementStateAssert
      Returns:
      this assertion object.
    • isNotPresent

      public FluentWebElementAssert isNotPresent()
      Description copied from interface: ElementStateAssert
      Checks if the element is not present.

      Example:

       assertThat(element).isNotPresent();
       
      Specified by:
      isNotPresent in interface ElementStateAssert
      Returns:
      this assertion object.
    • hasText

      public FluentWebElementAssert 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 FluentWebElementAssert hasTextContaining (String text)
      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:
      text - text to find
      Returns:
      this assertion object.
    • hasTextMatching

      public FluentWebElementAssert 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 FluentWebElementAssert 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 FluentWebElementAssert 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 FluentWebElementAssert 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 FluentWebElementAssert 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.
    • hasNotClass

      public FluentWebElementAssert 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.
    • hasClasses

      public FluentWebElementAssert 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.
    • hasNotClasses

      public FluentWebElementAssert hasNotClasses (String... classesToFind)
      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:
      classesToFind - classes to find the absence of
      Returns:
      this assertion object.
    • hasValue

      public FluentWebElementAssert 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 FluentWebElementAssert 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 FluentWebElementAssert 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 FluentWebElementAssert 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 FluentWebElementAssert 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.AbstractStringAssert hasAttribute (String attribute)
      Description copied from interface: ElementAttributeAssert
      Checks if the element has the given property.

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

      Examples:

      Validating the presence of an attribute on an element:

       assertThat(element).hasAttribute("href");
       

      Validating both the presence of an attribute on an element, and the value of that attribute:

       assertThat(element).hasAttribute("href").isEqualTo("https://duckduckgo.com");
       
      Specified by:
      hasAttribute in interface AttributeAssert<org.assertj.core.api.AbstractStringAssert>
      Specified by:
      hasAttribute in interface ElementAttributeAssert
      Parameters:
      attribute - the attribute to find
      Returns:
      a new AbstractStringAssert object with the actual attribute value
    • hasNotAttribute

      public FluentWebElementAssert 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.AbstractStringAssert>
      Parameters:
      attribute - attribute to find the absence of
      Returns:
      this assertion object.