private GrapheneContext getGrapheneContext(SearchContext searchContext) { if (searchContext instanceof GrapheneProxyInstance) { return ((GrapheneProxyInstance) searchContext).getGrapheneContext(); } else { return GrapheneContext.lastContext(); } } }
protected static GrapheneContext getContext(Object object) { if (!GrapheneProxy.isProxyInstance(object)) { throw new IllegalArgumentException("The parameter [object] has to be instance of " + GrapheneProxyInstance.class.getName() + ", but it is not. The given object is " + object + "."); } return ((GrapheneProxyInstance) object).getGrapheneContext(); }
public static JavascriptExecutor getExecutorFromElement(WebElement element) { Preconditions.checkNotNull(element, "The element cannot be null."); if (element instanceof GrapheneProxyInstance) { GrapheneContext context = ((GrapheneProxyInstance) element).getGrapheneContext(); return (JavascriptExecutor) context.getWebDriver(JavascriptExecutor.class); } throw new RuntimeException( "Cannot obtain JavascriptExecutor from element which is not an instance of GrapheneProxyInstance."); }
private GrapheneContext getGrapheneContext(SearchContext searchContext) { if (searchContext instanceof GrapheneProxyInstance) { return ((GrapheneProxyInstance) searchContext).getGrapheneContext(); } else { return GrapheneContext.lastContext(); } } }
protected static GrapheneContext getContext(Object object) { if (!GrapheneProxy.isProxyInstance(object)) { throw new IllegalArgumentException("The parameter [object] has to be instance of " + GrapheneProxyInstance.class.getName() + ", but it is not. The given object is " + object + "."); } return ((GrapheneProxyInstance) object).getGrapheneContext(); }
protected final <T> List<T> createPageFragmentList(final Class<T> clazz, final SearchContext searchContext, final By rootBy) { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getGrapheneContext(); List<T> result = GrapheneProxy.getProxyForFutureTarget(grapheneContext, new FutureTarget() { @Override public Object getTarget() { List<WebElement> elements = searchContext.findElements(rootBy); List<T> fragments = new ArrayList<T>(); for (int i = 0; i < elements.size(); i++) { fragments.add(createPageFragment(clazz, WebElementUtils.findElementLazily(rootBy, searchContext, i))); } return fragments; } }, List.class); return result; }
/** * Returns the default timeout for Ajax waiting in milliseconds. * * @param browser * @return */ public static long getWaitAjaxDefaultTimeout(WebDriver browser) { return 1000 * ((GrapheneProxyInstance) browser).getGrapheneContext().getConfiguration().getWaitAjaxInterval(); }
/** * Returns the default timeout for GUI waiting in milliseconds. * * @param browser * @return */ public static long getWaitGUIDefaultTimeout(WebDriver browser) { return 1000 * ((GrapheneProxyInstance) browser).getGrapheneContext().getConfiguration().getWaitGuiInterval(); }
public WebDriverWait<Void> waitAjax(WebDriver driver) { return new WebDriverWaitImpl<Void>(null, driver, ((GrapheneProxyInstance) driver).getGrapheneContext().getConfiguration().getWaitAjaxInterval()); }
public WebDriverWait<Void> waitGui(WebDriver driver) { return new WebDriverWaitImpl<Void>(null, driver, ((GrapheneProxyInstance) driver).getGrapheneContext().getConfiguration().getWaitGuiInterval()); }
public WebDriverWait<Void> waitAjax(WebDriver driver) { return new WebDriverWaitImpl<Void>(null, driver, ((GrapheneProxyInstance) driver).getGrapheneContext().getConfiguration().getWaitAjaxInterval()); }
public WebDriverWait<Void> waitGui(WebDriver driver) { return new WebDriverWaitImpl<Void>(null, driver, ((GrapheneProxyInstance) driver).getGrapheneContext().getConfiguration().getWaitGuiInterval()); }
public WebDriverWait<Void> waitModel(WebDriver driver) { return new WebDriverWaitImpl<Void>(null, driver, ((GrapheneProxyInstance) driver).getGrapheneContext().getConfiguration().getWaitModelInterval()); }
public WebDriverWait<Void> waitModel(WebDriver driver) { return new WebDriverWaitImpl<Void>(null, driver, ((GrapheneProxyInstance) driver).getGrapheneContext().getConfiguration().getWaitModelInterval()); }
protected final void setupPageFragment(SearchContext searchContext, Object target, Field field) { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getGrapheneContext(); // the by retrieved in this way is never null, by default it is ByIdOrName using field name By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); WebElement root = WebElementUtils.findElementLazily(rootBy, searchContext); Object pageFragment = createPageFragment(field.getType(), root); setValue(field, target, pageFragment); }
protected final void setupPageFragment(SearchContext searchContext, Object target, Field field) { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getGrapheneContext(); // the by retrieved in this way is never null, by default it is ByIdOrName using field name By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); WebElement root = WebElementUtils.findElementLazily(rootBy, searchContext); Object pageFragment = createPageFragment(field.getType(), root); setValue(field, target, pageFragment); }
private RequestGuardFactory getRequestGuardFactoryFor(Object target) { GrapheneContext context; if (GrapheneProxy.isProxyInstance(target)) { context = ((GrapheneProxyInstance) target).getGrapheneContext(); } else { context = context(); } return new RequestGuardFactory( JSInterfaceFactory.create(context, RequestGuard.class), JSInterfaceFactory.create(context, Document.class), context); }
private RequestGuardFactory getRequestGuardFactoryFor(Object target) { GrapheneContext context; if (GrapheneProxy.isProxyInstance(target)) { context = ((GrapheneProxyInstance) target).getGrapheneContext(); } else { context = context(); } return new RequestGuardFactory( JSInterfaceFactory.create(context, RequestGuard.class), JSInterfaceFactory.create(context, Document.class), context); }
protected final void setupPageFragmentList(SearchContext searchContext, Object target, Field field) throws ClassNotFoundException { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getGrapheneContext(); // the by retrieved in this way is never null, by default it is ByIdOrName using field name By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); List<?> pageFragments = createPageFragmentList(getListType(field), searchContext, rootBy); setValue(field, target, pageFragments); }
protected final void setupPageFragmentList(SearchContext searchContext, Object target, Field field) throws ClassNotFoundException { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getGrapheneContext(); // the by retrieved in this way is never null, by default it is ByIdOrName using field name By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); List<?> pageFragments = createPageFragmentList(getListType(field), searchContext, rootBy); setValue(field, target, pageFragments); }