Example usage for org.openqa.selenium.support.pagefactory.internal LocatingElementHandler LocatingElementHandler

List of usage examples for org.openqa.selenium.support.pagefactory.internal LocatingElementHandler LocatingElementHandler

Introduction

In this page you can find the example usage for org.openqa.selenium.support.pagefactory.internal LocatingElementHandler LocatingElementHandler.

Prototype

public LocatingElementHandler(ElementLocator locator) 

Source Link

Usage

From source file:com.cognifide.qa.bb.scope.current.CurrentWebElementProvider.java

License:Apache License

private WebElement getWebElementFromFactory(ElementLocatorFactory factory) {
    InvocationHandler handler = new LocatingElementHandler(
            ((ParentElementLocatorProvider) factory).getCurrentScope());
    return (WebElement) Proxy.newProxyInstance(WebElement.class.getClassLoader(),
            new Class[] { WebElement.class, WrapsElement.class, Locatable.class }, handler);
}

From source file:com.github.licanhua.test.framework.base.CustomFieldDecorator.java

License:Apache License

private WebElement proxyForLocator(ClassLoader loader, ElementLocator locator) {
    logger.debug("proxyForLocator : " + locator);
    InvocationHandler handler = new LocatingElementHandler(locator);

    WebElement proxy;//from  w  ww .jav  a  2  s  .  c  om
    proxy = (WebElement) Proxy.newProxyInstance(loader,
            new Class[] { WebElement.class, WrapsElement.class, Locatable.class }, handler);

    logger.debug("proxyForLocator complete : " + locator);
    return proxy;
}

From source file:com.oracle.pgbu.common.pagefactory.DefaultFieldDecorator.java

License:Apache License

protected WebElement proxyForLocator(ClassLoader loader, ElementLocator locator) {
    InvocationHandler handler = new LocatingElementHandler(locator);

    WebElement proxy;//from   www .  j  a va2s  .c  o  m
    proxy = (WebElement) Proxy.newProxyInstance(loader,
            new Class[] { WebElement.class, WrapsElement.class, Locatable.class }, handler);
    return proxy;
}

From source file:org.fluentlenium.core.Fluent.java

License:Apache License

private static void proxyElement(ElementLocatorFactory factory, Object page, Field field) {
    ElementLocator locator = factory.createLocator(field);
    if (locator == null) {
        return;//from ww w. j  a v  a 2s  .c  o m
    }

    InvocationHandler handler = new LocatingElementHandler(locator);
    WebElement proxy = (WebElement) java.lang.reflect.Proxy.newProxyInstance(page.getClass().getClassLoader(),
            new Class[] { WebElement.class }, handler);
    try {
        field.setAccessible(true);
        field.set(page, new FluentWebElement(proxy));
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.fluentlenium.core.FluentAdapter.java

License:Apache License

private static void proxyElement(ElementLocatorFactory factory, Object page, Field field) {
    ElementLocator locator = factory.createLocator(field);
    if (locator == null) {
        return;//  w  w w.j  ava  2  s . co  m
    }

    try {
        field.setAccessible(true);
        if (isFluentList(field)) {
            // LocatingElementListHandler is not a good choice, elements are FluentWebElement not WebElement.
            final InvocationHandler handler = new FluentListInvocationHandler(locator);
            FluentList<FluentWebElement> proxy = (FluentList<FluentWebElement>) Proxy.newProxyInstance(
                    page.getClass().getClassLoader(), new Class[] { FluentList.class }, handler);
            field.set(page, proxy);
        } else {
            final InvocationHandler handler = new LocatingElementHandler(locator);
            WebElement proxy = (WebElement) Proxy.newProxyInstance(page.getClass().getClassLoader(),
                    new Class[] { WebElement.class }, handler);
            field.set(page, field.getType().getConstructor(WebElement.class).newInstance(proxy));
        }
    } catch (Exception e) {
        throw new RuntimeException(
                "Unable to find an accessible constructor with an argument of type WebElement in "
                        + field.getType(),
                e);
    }
}

From source file:org.fluentlenium.core.test.FluentTest.java

License:Apache License

private static void proxyElement(ElementLocatorFactory factory, Object page, Field field) {
    ElementLocator locator = factory.createLocator(field);
    if (locator == null) {
        return;/*ww w  .  j  ava  2  s.com*/
    }

    InvocationHandler handler = new LocatingElementHandler(locator);
    WebElement proxy = (WebElement) Proxy.newProxyInstance(page.getClass().getClassLoader(),
            new Class[] { WebElement.class }, handler);
    try {
        field.setAccessible(true);
        field.set(page, new FluentWebElement(proxy));
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}