|
34 | 34 | public class ElementAwareWebDriverListener implements MethodCallListener, ProxyAwareListener {
|
35 | 35 | private WebDriver parent;
|
36 | 36 |
|
| 37 | + /** |
| 38 | + * Attaches the WebDriver proxy instance to this listener. |
| 39 | + * <p> |
| 40 | + * The listener stores the WebDriver instance to associate it as parent to RemoteWebElement proxies. |
| 41 | + * |
| 42 | + * @param proxy A proxy instance of {@link WebDriver}. |
| 43 | + */ |
37 | 44 | @Override
|
38 | 45 | public void attachProxyInstance(Object proxy) {
|
39 | 46 | if (proxy instanceof WebDriver) {
|
40 | 47 | this.parent = (WebDriver) proxy;
|
41 | 48 | }
|
42 | 49 | }
|
43 | 50 |
|
| 51 | + /** |
| 52 | + * Intercepts method calls on a proxied WebDriver. |
| 53 | + * <p> |
| 54 | + * If the result of the method call is a {@link RemoteWebElement}, |
| 55 | + * it is wrapped with a proxy to allow further interception of RemoteWebElement method calls. |
| 56 | + * If the result is a list, each item is checked, and all RemoteWebElements are |
| 57 | + * individually proxied. All other return types are passed through unmodified. |
| 58 | + * Avoid overriding this method, it will alter the behaviour of the listener. |
| 59 | + * |
| 60 | + * @param obj The object on which the method was invoked. |
| 61 | + * @param method The method being invoked. |
| 62 | + * @param args The arguments passed to the method. |
| 63 | + * @param original A {@link Callable} that represents the original method execution. |
| 64 | + * @return The (possibly wrapped) result of the method call. |
| 65 | + * @throws Throwable if the original method or any wrapping logic throws an exception. |
| 66 | + */ |
44 | 67 | @Override
|
45 | 68 | public Object call(Object obj, Method method, Object[] args, Callable<?> original) throws Throwable {
|
46 | 69 | Object result = original.call();
|
|
0 commit comments