Class ElementAwareWebDriverListener

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void attachProxyInstance​(java.lang.Object proxy)
      Attaches the WebDriver proxy instance to this listener.
      java.lang.Object call​(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args, java.util.concurrent.Callable<?> original)
      Intercepts method calls on a proxied WebDriver.
      • Methods inherited from class java.lang.Object

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

      • ElementAwareWebDriverListener

        public ElementAwareWebDriverListener()
    • Method Detail

      • attachProxyInstance

        public void attachProxyInstance​(java.lang.Object proxy)
        Attaches the WebDriver proxy instance to this listener.

        The listener stores the WebDriver instance to associate it as parent to RemoteWebElement proxies.

        Specified by:
        attachProxyInstance in interface ProxyAwareListener
        Parameters:
        proxy - A proxy instance of WebDriver.
      • call

        public java.lang.Object call​(java.lang.Object obj,
                                     java.lang.reflect.Method method,
                                     java.lang.Object[] args,
                                     java.util.concurrent.Callable<?> original)
                              throws java.lang.Throwable
        Intercepts method calls on a proxied WebDriver.

        If the result of the method call is a RemoteWebElement, it is wrapped with a proxy to allow further interception of RemoteWebElement method calls. If the result is a list, each item is checked, and all RemoteWebElements are individually proxied. All other return types are passed through unmodified. Avoid overriding this method, it will alter the behaviour of the listener.

        Specified by:
        call in interface MethodCallListener
        Parameters:
        obj - The object on which the method was invoked.
        method - The method being invoked.
        args - The arguments passed to the method.
        original - A Callable that represents the original method execution.
        Returns:
        The (possibly wrapped) result of the method call.
        Throws:
        java.lang.Throwable - if the original method or any wrapping logic throws an exception.