Examples of GrapheneContext


Examples of org.jboss.arquillian.graphene.context.GrapheneContext

        return type == this.returnType;
    }

    protected <BASE> BASE base(final Annotation[] annotations) {

        GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations));
        return (BASE) context.getWebDriver(returnType);
    }
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

        @Override
        protected <BASE> BASE base(final Annotation[] annotations) {
            final GrapheneProxy.FutureTarget futureTarget = new GrapheneProxy.FutureTarget() {
                @Override
                public Object getTarget() {
                    GrapheneContext context = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(annotations));
                    return context.getWebDriver(mediatorType);
                }
            };

            GrapheneProxyHandler mediatorHandler = new GrapheneProxyHandler(futureTarget) {
                @Override
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

        return result;
    }

    public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) {
        T result = null;
        GrapheneContext grapheneContext = GrapheneContext.getContextFor(browserQualifier);
        WebDriver browser = grapheneContext.getWebDriver();
        try {
            result = PageObjectEnricher.setupPage(grapheneContext, browser, pageObject);
        } catch (Exception e) {
            throw new GrapheneTestEnricherException("Error while initializing: " + pageObject, e);
        }
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

    public static final By BY_HTML = By.tagName("html");

    public static JavascriptExecutor getExecutorFromElement(WebElement element) {
        Preconditions.checkNotNull(element, "The element cannot be null.");
        if (element instanceof GrapheneProxyInstance) {
            GrapheneContext context = ((GrapheneProxyInstance) element).getContext();
            return (JavascriptExecutor) context.getWebDriver(JavascriptExecutor.class);
        }
        throw new RuntimeException(
            "Cannot obtain JavascriptExecutor from element which is not an instance of GrapheneProxyInstance.");
    }
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

    /**
     * Returns active (focused) element - if no element is focused (it means body element is active), null is returned
     */
    public static WebElement retrieveActiveElement() {
        GrapheneContext context = GrapheneContext.getContextFor(Default.class);
        WebElement element = JSInterfaceFactory.create(context, FocusRetriever.class).getActiveElement();
        if ("body".equals(element.getTagName())) {
            return null;
        }
        return element;
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

    /**
     * Wraps the {@link WebDriver} instance provided by {@link Drone} in a proxy and sets the driver into context
     */
    @Override
    public WebDriver enhance(WebDriver driver, Class<? extends Annotation> qualifier) {
        GrapheneContext grapheneContext = GrapheneContext.setContextFor(configuration.get(), driver, qualifier);
        Class<?>[] interfaces = GrapheneProxyUtil.getInterfaces(driver.getClass());
        return grapheneContext.getWebDriver(interfaces);
    }
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

        LocationEnricher locationEnricher = new LocationEnricher();
        return locationEnricher.goTo(pageObject, browserQualifier);
    }

    private RequestGuardFactory getRequestGuardFactoryFor(Object target) {
        GrapheneContext context;
        if (GrapheneProxy.isProxyInstance(target)) {
            context = ((GrapheneProxyInstance) target).getContext();
        } else {
            context = context();
        }
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

                JSInterfaceFactory.create(context, Document.class),
                context);
    }

    private GrapheneContext context() {
        GrapheneContext context = GrapheneContext.lastContext();
        if (context == null) {
            throw new IllegalStateException("The last used Graphene context is not available.");
        }
        return context;
    }
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

        for (Field field : fields) {
            try {
                final Field finalField = field;
                if (isValidClass(field.getType())) {
                    final SearchContext localSearchContext;
                    GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getContext();
                    if (grapheneContext == null) {
                        grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations()));
                        localSearchContext = grapheneContext.getWebDriver(SearchContext.class);
                    } else {
                        localSearchContext = searchContext;
                    }
                    final By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy());
                    Object wrapper;
                    try {
                        wrapper = createWrapper(grapheneContext, field.getType(), WebElementUtils.findElementLazily(rootBy, localSearchContext));
                    } catch (Exception e) {
                        throw new GrapheneTestEnricherException("Can't instantiate element wrapper " + target.getClass() + "." + field.getName() + " of type " + field.getType(), e);
                    }
                    try {
                        setValue(field, target, wrapper);
                    } catch (Exception e) {
                        throw new GrapheneTestEnricherException("Can't set a value to the " + target.getClass() + "." + field.getName() + ".", e);
                    }
                } else if (field.getType().isAssignableFrom(List.class)
                        && isValidClass(getListType(field))) {
                    final SearchContext localSearchContext;
                    GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getContext();
                    if (grapheneContext == null) {
                        grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations()));
                        localSearchContext = grapheneContext.getWebDriver(SearchContext.class);
                    } else {
                        localSearchContext = searchContext;
                    }
                    final By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy());
                    try {
View Full Code Here

Examples of org.jboss.arquillian.graphene.context.GrapheneContext

        return result;
    }

    public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) {
        T result = null;
        GrapheneContext grapheneContext = GrapheneContext.getContextFor(browserQualifier);
        WebDriver browser = grapheneContext.getWebDriver();
        try {
            result = PageObjectEnricher.setupPage(grapheneContext, browser, pageObject);
        } catch (Exception e) {
            throw new GrapheneTestEnricherException("Error while initializing: " + pageObject, e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.