def when_loaded
      # Get original loaded value, in case we are nested
      # inside another when_loaded block.
      previously_loaded = loaded

      # Within the block, check (and cache) loaded?, to see whether the
      # page has indeed loaded according to the rules defined by the user.
      self.loaded = loaded?

      # If the page hasn't loaded. Then crash and return the error message.
      # If one isn't defined, just return the Error code.
      raise SitePrism::FailedLoadValidationError, load_error unless loaded

      # Return the yield value of the block if one was supplied.
      yield self if block_given?
    ensure
      self.loaded = previously_loaded
    end
def when_loaded
      # Get original loaded value, in case we are nested
      # inside another when_loaded block.
      previously_loaded = loaded

      # Within the block, check (and cache) loaded?, to see whether the
      # page has indeed loaded according to the rules defined by the user.
      self.loaded = loaded?

      # If the page hasn't loaded. Then crash and return the error message.
      # If one isn't defined, just return the Error code.
      raise SitePrism::FailedLoadValidationError, load_error unless loaded

      # Return the yield value of the block if one was supplied.
      yield self if block_given?
    ensure
      self.loaded = previously_loaded
    end
Executes the given block after the page is loaded.

 The loadable object instance is yielded into the block.