@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { return GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { return GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); }
@Override public Object[] resolve(Method method) { List<Integer> indicesOfInitialPage = getIndexOfParameterWithAnnotation(InitialPage.class, method); if (indicesOfInitialPage.isEmpty()) { return new Object[method.getParameterTypes().length]; } Object[] results = new Object[method.getParameterTypes().length]; Set<Class<?>> usedQualifiers = new HashSet<Class<?>>(); for (Integer indexOfInitialPage : indicesOfInitialPage) { Class<?> qualifier = ReflectionHelper.getQualifier(method.getParameterAnnotations()[indexOfInitialPage]); if (usedQualifiers.contains(qualifier)) { throw new IllegalArgumentException("There are multiple @InitialPage parameters using the same qualifier"); } usedQualifiers.add(qualifier); Class<?>[] parameterTypes = method.getParameterTypes(); results[indexOfInitialPage] = goTo(parameterTypes[indexOfInitialPage], qualifier); } return results; }
@Override public Object[] resolve(Method method) { List<Integer> indicesOfInitialPage = getIndexOfParameterWithAnnotation(InitialPage.class, method); if (indicesOfInitialPage.isEmpty()) { return new Object[method.getParameterTypes().length]; } Object[] results = new Object[method.getParameterTypes().length]; Set<Class<?>> usedQualifiers = new HashSet<Class<?>>(); for (Integer indexOfInitialPage : indicesOfInitialPage) { Class<?> qualifier = ReflectionHelper.getQualifier(method.getParameterAnnotations()[indexOfInitialPage]); if (usedQualifiers.contains(qualifier)) { throw new IllegalArgumentException("There are multiple @InitialPage parameters using the same qualifier"); } usedQualifiers.add(qualifier); Class<?>[] parameterTypes = method.getParameterTypes(); results[indexOfInitialPage] = goTo(parameterTypes[indexOfInitialPage], qualifier); } return results; }
@Override public void enrich(final SearchContext searchContext, Object target) { Collection<Field> fields = ReflectionHelper.getFieldsWithAnnotation(target.getClass(), JavaScript.class); for (Field field : fields) { GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getGrapheneContext(); if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); } if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(target, JSInterfaceFactory.create(grapheneContext, field.getType())); } catch (Exception e) { throw new IllegalStateException("Can't inject value to the field '" + field.getName() + "' declared in class '" + field.getDeclaringClass().getName() + "'", e); } } }
@Override public Object getTarget() { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations)); return context.getWebDriver(mediatorType); } };
@Override public Object getTarget() { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations)); return context.getWebDriver(mediatorType); } };
@Override public void enrich(final SearchContext searchContext, Object target) { Collection<Field> fields = ReflectionHelper.getFieldsWithAnnotation(target.getClass(), JavaScript.class); for (Field field : fields) { GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getGrapheneContext(); if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); } if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(target, JSInterfaceFactory.create(grapheneContext, field.getType())); } catch (Exception e) { throw new IllegalStateException("Can't inject value to the field '" + field.getName() + "' declared in class '" + field.getDeclaringClass().getName() + "'", e); } } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); try { return context.getWebDriver(Class.forName(getReturnType())); } catch (ClassNotFoundException ex) { //the external users: // - does not have any chance to build a test with classes which are not added on classpath //the intern usage of Providers: // - the class path may contain a different version of Selenium // - problem with internal use of Actions, Javascript, Mouse throw new IllegalStateException("The class of the provider is not on the class path.", ex); } } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(qualifiers)); try { return context.getWebDriver(Class.forName(getReturnType())); } catch (ClassNotFoundException ex) { //the external users: // - does not have any chance to build a test with classes which are not added on classpath //the intern usage of Providers: // - the class path may contain a different version of Selenium // - problem with internal use of Actions, Javascript, Mouse throw new IllegalStateException("The class of the provider is not on the class path.", ex); } } }
@Override public void enrich(final SearchContext searchContext, Object target) { try { List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target); for (Field field : fields) { GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getGrapheneContext(); final SearchContext localSearchContext; if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else { localSearchContext = searchContext; } //by should never by null, by default it is ByIdOrName using field name By by = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); // WebElement if (field.getType().isAssignableFrom(WebElement.class)) { WebElement element = WebElementUtils.findElementLazily(by, localSearchContext); setValue(field, target, element); // List<WebElement> } else if (field.getType().isAssignableFrom(List.class) && getListType(field).isAssignableFrom(WebElement.class)) { List<WebElement> elements = WebElementUtils.findElementsLazily(by, localSearchContext); setValue(field, target, elements); } } } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public void enrich(final SearchContext searchContext, Object target) { try { List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target); for (Field field : fields) { GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getGrapheneContext(); final SearchContext localSearchContext; if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else { localSearchContext = searchContext; } //by should never by null, by default it is ByIdOrName using field name By by = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); // WebElement if (field.getType().isAssignableFrom(WebElement.class)) { WebElement element = WebElementUtils.findElementLazily(by, localSearchContext); setValue(field, target, element); // List<WebElement> } else if (field.getType().isAssignableFrom(List.class) && getListType(field).isAssignableFrom(WebElement.class)) { List<WebElement> elements = WebElementUtils.findElementsLazily(by, localSearchContext); setValue(field, target, elements); } } } catch (ClassNotFoundException e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public void enrich(final SearchContext searchContext, Object target) { List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target); for (Field field : fields) { GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext) .getGrapheneContext(); final SearchContext localSearchContext; if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else { localSearchContext = searchContext; } // Page fragment if (isPageFragmentClass(field.getType(), target)) { setupPageFragment(localSearchContext, target, field); // List<Page fragment> } else { try { if (field.getType().isAssignableFrom(List.class) && isPageFragmentClass(getListType(field), target)) { setupPageFragmentList(localSearchContext, target, field); } } catch (ClassNotFoundException e) { throw new PageFragmentInitializationException(e.getMessage(), e); } } } }
if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations)); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else {
@Override public void enrich(final SearchContext searchContext, Object target) { List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target); for (Field field : fields) { GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext) .getGrapheneContext(); final SearchContext localSearchContext; if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else { localSearchContext = searchContext; } // Page fragment if (isPageFragmentClass(field.getType(), target)) { setupPageFragment(localSearchContext, target, field); // List<Page fragment> } else { try { if (field.getType().isAssignableFrom(List.class) && isPageFragmentClass(getListType(field), target)) { setupPageFragmentList(localSearchContext, target, field); } } catch (ClassNotFoundException e) { throw new PageFragmentInitializationException(e.getMessage(), e); } } } }
if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations)); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else {
.getGrapheneContext(); if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else { .getGrapheneContext(); if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else {
.getGrapheneContext(); if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else { .getGrapheneContext(); if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); localSearchContext = grapheneContext.getWebDriver(SearchContext.class); } else {