@Override public Object call() throws Exception { try { return finalInvocationContext.invoke(); } catch (Throwable e) { if (e instanceof Exception) { throw (Exception) e; } else if (e instanceof AssertionError) { throw (AssertionError) e; } else { throw new IllegalStateException("Can't invoke method " + method.getName() + ".", e); } } } });
@Override public Object call() throws Exception { try { return finalInvocationContext.invoke(); } catch (Throwable e) { if (e instanceof Exception) { throw (Exception) e; } else if (e instanceof AssertionError) { throw (AssertionError) e; } else { throw new IllegalStateException("Can't invoke method " + method.getName() + ".", e); } } } });
@Override public Boolean apply(WebDriver driver) { try { result.set(context.invoke()); return true; } catch (StaleElementReferenceException e) { staleness.set(e); return false; } catch (Throwable e) { failure.set(e); return true; } } });
@Override public Boolean apply(WebDriver driver) { try { result.set(context.invoke()); return true; } catch (StaleElementReferenceException e) { staleness.set(e); return false; } catch (Throwable e) { failure.set(e); return true; } } });
public Object intercept(InvocationContext context) throws Throwable { interceptor_registered_before_test_invoked = true; return context.invoke(); } public int getPrecedence() {
@Override public Object intercept(InvocationContext context) throws Throwable { invoked = true; return context.invoke(); }
@Override public Object intercept(InvocationContext context) throws Throwable { invoked = true; return context.invoke(); } @Override
@Override public Object intercept(InvocationContext context) throws Throwable { return context.invoke(); }
@Override public Object intercept(InvocationContext context) throws Throwable { counter.incrementAndGet(); return context.invoke(); } @Override
@Override public Object answer(InvocationOnMock invocation) throws Throwable { return ((InvocationContext) invocation.getArguments()[0]).invoke(); } };
@Override public Object intercept(InvocationContext context) throws Throwable { if (context.getMethod().getName().equals(GET_METHOD_NAME)) { tryToLoadPage((WebDriver) context.getTarget(), String.valueOf(context.getArguments()[0])); return null;// skip any other interceptors } else { return context.invoke();// invoke method normally } }
return originalContext.invoke();
@Override public Object intercept(final InvocationContext context) throws Throwable { GrapheneProxy.FutureTarget future = new GrapheneProxy.FutureTarget() { @Override public Object getTarget() { return context.getProxy(); } }; if (methodsEqual(context.getMethod(), SearchContext.class.getDeclaredMethod("findElement", By.class))) { return WebElementUtils.findElement(context.getGrapheneContext(), (By) context.getArguments()[0], future); } else if (methodsEqual(context.getMethod(), SearchContext.class.getDeclaredMethod("findElements", By.class))) { return WebElementUtils.findElementsLazily(context.getGrapheneContext(), (By) context.getArguments()[0], future); } else { return context.invoke(); } }
@Override public Object intercept(final InvocationContext context) throws Throwable { GrapheneProxy.FutureTarget future = new GrapheneProxy.FutureTarget() { @Override public Object getTarget() { return context.getProxy(); } }; if (methodsEqual(context.getMethod(), SearchContext.class.getDeclaredMethod("findElement", By.class))) { return WebElementUtils.findElement(context.getGrapheneContext(), (By) context.getArguments()[0], future); } else if (methodsEqual(context.getMethod(), SearchContext.class.getDeclaredMethod("findElements", By.class))) { return WebElementUtils.findElementsLazily(context.getGrapheneContext(), (By) context.getArguments()[0], future); } else { return context.invoke(); } }
@Override public Object intercept(InvocationContext context) throws Throwable { guard.clearRequestDone(); Object result = context.invoke(); RequestType requestType; if (strict) { requestType = waitForRequestChange(); } else { requestType = waitForRequestType(requestExpected); } if (requestType.equals(requestExpected)) { waitForRequestFinished(); } else { throw new RequestGuardException(requestExpected, requestType); } return result; }
@Override public Object intercept(InvocationContext context) throws Throwable { guard.clearRequestDone(); Object result = context.invoke(); RequestType requestType; if (strict) { requestType = waitForRequestChange(); } else { requestType = waitForRequestType(requestExpected); } if (requestType.equals(requestExpected)) { waitForRequestFinished(); } else { throw new RequestGuardException(requestExpected, requestType); } return result; }
@Override public Object intercept(InvocationContext context) throws Throwable { List<Interceptor> previouslyRegistered = interceptorRegistryService.unregisterAll(); Object result = context.invoke(); if(previouslyRegistered.isEmpty()) { return result; } Method interceptedMethod = context.getMethod(); if (isInterceptedMethodAllowed(interceptedMethod)) { When when = When.ON_EVERY_ACTION; takeScreenshot.getMetaData() .setOptionalDescription(interceptedMethod.getName() + Integer.toString(counter++)); DefaultFileNameBuilder nameBuilder = new DefaultFileNameBuilder(); String screenshotName = nameBuilder .withMetaData(takeScreenshot.getMetaData()) .withStage(when) .withResourceIdentifier( ResourceIdentifierFactory.getResoruceIdentifier(takeScreenshot.getMetaData(), when)) .build(); takeScreenshot.setFileName(screenshotName); takeScreenshot.setWhen(When.ON_EVERY_ACTION); takeScreenshotAndReport(); } interceptorRegistryService.registerAll(previouslyRegistered); return result; }
@Override public Object intercept(InvocationContext context) throws Throwable { List<Interceptor> previouslyRegistered = interceptorRegistryService.unregisterAll(); Object result = context.invoke(); if(previouslyRegistered.isEmpty()) { return result; } Method interceptedMethod = context.getMethod(); if (isInterceptedMethodAllowed(interceptedMethod)) { When when = When.ON_EVERY_ACTION; takeScreenshot.getMetaData() .setOptionalDescription(interceptedMethod.getName() + Integer.toString(counter++)); DefaultFileNameBuilder nameBuilder = new DefaultFileNameBuilder(); String screenshotName = nameBuilder .withMetaData(takeScreenshot.getMetaData()) .withStage(when) .withResourceIdentifier( ResourceIdentifierFactory.getResoruceIdentifier(takeScreenshot.getMetaData(), when)) .build(); takeScreenshot.setFileName(screenshotName); takeScreenshot.setWhen(When.ON_EVERY_ACTION); takeScreenshotAndReport(); } interceptorRegistryService.registerAll(previouslyRegistered); return result; }
@Override public Object intercept(InvocationContext context) throws Throwable { WebDriver browser = context.getGrapheneContext().getWebDriver(); if (indexOfFrame != -1) { browser.switchTo().frame(indexOfFrame); } else if (nameOrIdOfFrame != null) { browser.switchTo().frame(nameOrIdOfFrame); } Object result = null; try { result = context.invoke(); } finally { browser.switchTo().defaultContent(); } if (result instanceof GrapheneProxyInstance) { ((GrapheneProxyInstance) result).registerInterceptor(this); } return result; }
@Override public Object intercept(InvocationContext context) throws Throwable { WebDriver browser = context.getGrapheneContext().getWebDriver(); if (indexOfFrame != -1) { browser.switchTo().frame(indexOfFrame); } else if (nameOrIdOfFrame != null) { browser.switchTo().frame(nameOrIdOfFrame); } Object result = null; try { result = context.invoke(); } finally { browser.switchTo().defaultContent(); } if (result instanceof GrapheneProxyInstance) { ((GrapheneProxyInstance) result).registerInterceptor(this); } return result; }