Tabnine Logo
PageFragmentEnricher
Code IndexAdd Tabnine to your IDE (free)

How to use
PageFragmentEnricher
in
org.jboss.arquillian.graphene.enricher

Best Java code snippets using org.jboss.arquillian.graphene.enricher.PageFragmentEnricher (Showing top 17 results out of 315)

origin: arquillian/arquillian-graphene

public <T> T createPageFragment(Class<T> clazz, WebElement root) {
  return PageFragmentEnricher.createPageFragment(clazz, root);
}
origin: arquillian/arquillian-graphene

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);
}
origin: arquillian/arquillian-graphene

private static Class<?> extractWebElementType(Class<?> clazz) {
  List<Class<?>> interfaces = Arrays.asList(clazz.getInterfaces());
  if (interfaces.contains(GrapheneElement.class)) {
    return GrapheneElement.class;
  } else if (interfaces.contains(WebElement.class)) {
    return WebElement.class;
  } else {
    Class<?> superclass = clazz.getSuperclass();
    if (!Object.class.equals(superclass)) {
      return extractWebElementType(superclass);
    }
  }
  return null;
}
origin: arquillian/arquillian-graphene

  Class<?> webElementInterface = extractWebElementType(clazz);
  if (webElementInterface != null) {
    pageFragment = createProxyDelegatingToRoot(root, clazz, webElementInterface);
  } else {
    pageFragment = instantiate(clazz);
    setValue(roots.get(0), pageFragment, root);
  enrichRecursively(root, pageFragment);
  T proxy = GrapheneProxy.getProxyForHandler(GrapheneContextualHandler.forTarget(grapheneContext, pageFragment),
    clazz);
  enrichRecursively(root, proxy); // because of possibility of direct access to attributes from test class
  return proxy;
} catch (NoSuchMethodException ex) {
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

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);
}
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

@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);
      }
    }
  }
}
origin: arquillian/arquillian-graphene

@Before
public void prepareServiceLoader() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
  grapheneEnricher = new GrapheneEnricher();
  Instance<GrapheneConfiguration> configuration = new Instance() {
    @Override
    public Object get() {
      return new GrapheneConfiguration();
    }
  };
  webElementEnricher = new WebElementEnricher(configuration);
  pageObjectEnricher = new PageObjectEnricher();
  pageFragmentEnricher = new PageFragmentEnricher(configuration);
  when(serviceLoaderInstance.get()).thenReturn(serviceLoader);
  when(serviceLoader.all(TestEnricher.class)).thenReturn(Arrays.asList(grapheneEnricher));
  when(serviceLoader.all(SearchContextTestEnricher.class)).thenReturn(Arrays.asList(webElementEnricher, pageObjectEnricher, pageFragmentEnricher));
  for (Object o: Arrays.asList(grapheneEnricher, webElementEnricher, pageObjectEnricher, pageFragmentEnricher)) {
    Field serviceLoaderField;
    if (o instanceof SearchContextTestEnricher) {
      serviceLoaderField = AbstractSearchContextEnricher.class.getDeclaredField("serviceLoader");
    } else {
      serviceLoaderField = o.getClass().getDeclaredField("serviceLoader");
    }
    if (!serviceLoaderField.isAccessible()) {
      serviceLoaderField.setAccessible(true);
    }
    serviceLoaderField.set(o, serviceLoaderInstance);
  }
  GrapheneContext.setContextFor(new GrapheneConfiguration(), browser, Default.class);
  GrapheneRuntime.pushInstance(new DefaultGrapheneRuntime());
}
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

  Class<?> webElementInterface = extractWebElementType(clazz);
  if (webElementInterface != null) {
    pageFragment = createProxyDelegatingToRoot(root, clazz, webElementInterface);
  } else {
    pageFragment = instantiate(clazz);
    setValue(roots.get(0), pageFragment, root);
  enrichRecursively(root, pageFragment);
  T proxy = GrapheneProxy.getProxyForHandler(GrapheneContextualHandler.forTarget(grapheneContext, pageFragment),
    clazz);
  enrichRecursively(root, proxy); // because of possibility of direct access to attributes from test class
  return proxy;
} catch (NoSuchMethodException ex) {
origin: arquillian/arquillian-graphene

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);
}
origin: arquillian/arquillian-graphene

@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);
      }
    }
  }
}
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

public <T> T createPageFragment(Class<T> clazz, WebElement root) {
  return PageFragmentEnricher.createPageFragment(clazz, root);
}
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

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);
}
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

private static Class<?> extractWebElementType(Class<?> clazz) {
  List<Class<?>> interfaces = Arrays.asList(clazz.getInterfaces());
  if (interfaces.contains(GrapheneElement.class)) {
    return GrapheneElement.class;
  } else if (interfaces.contains(WebElement.class)) {
    return WebElement.class;
  } else {
    Class<?> superclass = clazz.getSuperclass();
    if (!Object.class.equals(superclass)) {
      return extractWebElementType(superclass);
    }
  }
  return null;
}
origin: arquillian/continuous-enterprise-development

  public <T extends SelfAwareFragment> T getResource(Class<T> fragment) {
    return PageFragmentEnricher.createPageFragment(fragment, resource);
  }
}
origin: arquillian/arquillian-graphene

@Override
public <T> T getContent(Class<T> clazz) {
  return PageFragmentEnricher.createPageFragment(clazz, root);
}
origin: org.jboss.arquillian.graphene/graphene-webdriver-impl

  @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);
origin: arquillian/arquillian-graphene

  @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);
org.jboss.arquillian.graphene.enricherPageFragmentEnricher

Javadoc

Enricher injecting page fragments ( FindBy annotation is used) to the fields of the given object.

Most used methods

  • createPageFragment
  • <init>
  • createPageFragmentList
  • createProxyDelegatingToRoot
  • enrichRecursively
  • extractWebElementType
  • getListType
  • instantiate
  • isPageFragmentClass
  • setValue
  • setupPageFragment
  • setupPageFragmentList
  • setupPageFragment,
  • setupPageFragmentList

Popular in Java

  • Reading from database using SQL prepared statement
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • startActivity (Activity)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JCheckBox (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now