Interface SearchContext

All Known Subinterfaces:
Attribute, Document, Element, FormControlElement, FormElement, FrameElement, ImageElement, InputElement, Node, OptionElement, SelectElement, TextAreaElement

public interface SearchContext
Base interface for search methods that must be inherited by the DOM interfaces that want to have search mechanisms.
  • Method Details

    • findElementsByClassName

      List<Element> findElementsByClassName(String className)
      Returns an immutable list of the Element objects found in the current search context by the given className. Returns an empty list if no elements were found.
      Parameters:
      className - a string that represents the class attribute of the HTML element
      Throws:
      IllegalArgumentException - if the given className is empty
      ObjectClosedException - when this instance is closed
    • findElementsByCssSelector

      List<Element> findElementsByCssSelector(String cssSelector)
      Returns an immutable list of the Element objects found in the current search context by the given cssSelector. Returns an empty list if no elements were found.
      Parameters:
      cssSelector - a string that represents the CSS selector
      Throws:
      IllegalArgumentException - if the given cssSelector is empty
      ObjectClosedException - when this instance is closed
    • findElementsById

      List<Element> findElementsById(String id)
      Returns an immutable list of the Element objects found in the current search context by the given id. Returns an empty list if no elements were found.
      Parameters:
      id - a string that represents the id attribute of the HTML element
      Throws:
      IllegalArgumentException - if the given id is empty
      ObjectClosedException - when this instance is closed
    • findElementsByName

      List<Element> findElementsByName(String name)
      Returns an immutable list of the Element objects found in the current search context by the given name. Returns an empty list if no elements were found.
      Parameters:
      name - a string that represents the name attribute of the HTML element
      Throws:
      IllegalArgumentException - if the given name is empty
      ObjectClosedException - when this instance is closed
    • findElementsByTagName

      List<Element> findElementsByTagName(String tagName)
      Returns an immutable list of the Element objects found in the current search context by the given tagName. Returns an empty list if no elements were found.
      Parameters:
      tagName - a string that represents the tag name of the HTML element
      Throws:
      IllegalArgumentException - if the given tagName is empty
      ObjectClosedException - when this instance is closed
    • findElementByClassName

      Optional<Element> findElementByClassName(String className)
      Returns the first Element object found in the current search context by the given className. Returns an empty Optional if no element was found.
      Parameters:
      className - a string that represents the class attribute of the HTML element
      Throws:
      IllegalArgumentException - if the given className is empty
      ObjectClosedException - when this instance is closed
    • findElementByCssSelector

      Optional<Element> findElementByCssSelector(String cssSelector)
      Returns the first Element object found in the current search context by the given cssSelector. Returns an empty Optional if no element was found.
      Parameters:
      cssSelector - a string that represents the CSS selector
      Throws:
      IllegalArgumentException - if the given cssSelector is empty
      ObjectClosedException - when this instance is closed
    • findElementById

      Optional<Element> findElementById(String id)
      Returns the first Element object found in the current search context by the given id. Returns an empty Optional if no element was found.
      Parameters:
      id - a string that represents the id attribute of the HTML element
      Throws:
      IllegalArgumentException - if the given id is empty
      ObjectClosedException - when this instance is closed
    • findElementByName

      Optional<Element> findElementByName(String name)
      Returns the first Element object found in the current search context by the given name. Returns an empty Optional if no element was found.
      Parameters:
      name - a string that represents the name attribute of the HTML element
      Throws:
      IllegalArgumentException - if the given name is empty
      ObjectClosedException - when this instance is closed
    • findElementByTagName

      Optional<Element> findElementByTagName(String tagName)
      Returns the first Element object found in the current search context by the given tagName. Returns an empty Optional if no element was found.
      Parameters:
      tagName - a string that represents the tag name of the HTML element
      Throws:
      IllegalArgumentException - if the given tagName is empty
      ObjectClosedException - when this instance is closed