Class LoadableComponent<T extends LoadableComponent<T>>

java.lang.Object
org.openqa.selenium.support.ui.LoadableComponent<T>
Type Parameters:
T - The type to be returned (normally the subclass' type)
Direct Known Subclasses:
SlowLoadableComponent

public abstract class LoadableComponent<T extends LoadableComponent<T>> extends Object
Represents any abstraction of something that can be loaded. This may be an entire web page, or simply a component within that page (such as a login box or menu) or even a service. The expected usage is:
 new HypotheticalComponent().get();
 

After the get() method is called, the component will be loaded and ready for use. This is verified using Assert.assertTrue so expect to catch an Error rather than an Exception when errors occur. *

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Ensure that the component is currently loaded.
    protected abstract void
    Determine whether or not the component is loaded.
    protected abstract void
    When this method returns, the component modeled by the subclass should be fully loaded.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LoadableComponent

      public LoadableComponent()
  • Method Details

    • get

      public T get()
      Ensure that the component is currently loaded.
      Returns:
      The component.
      Throws:
      Error - when the component cannot be loaded.
    • load

      protected abstract void load()
      When this method returns, the component modeled by the subclass should be fully loaded. This subclass is expected to navigate to an appropriate page should this be necessary.
    • isLoaded

      protected abstract void isLoaded() throws Error
      Determine whether or not the component is loaded. When the component is loaded, this method will return, but when it is not loaded, an Error should be thrown. This also allows for complex checking and error reporting when loading a page, which in turn supports better error reporting when a page fails to load.

      This behaviour makes it readily visible when a page has not been loaded successfully, and because an error and not an exception is thrown tests should fail as expected. By using Error, we also allow the use of junit's "Assert.assert*" methods

      Throws:
      Error - when the page is not loaded.