org.openqa.selenium.internal.WrapsElement Java Examples

The following examples show how to use org.openqa.selenium.internal.WrapsElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrameAwareWebElementTransformer.java    From teasy with MIT License 5 votes vote down vote up
@Override
public WebElement apply(final WebElement element) {
    return (WebElement) newProxyInstance(
            getClass().getClassLoader(),
            new Class[]{WebElement.class, WrapsElement.class, Locatable.class, HasIdentity.class},
            invocationHandlerFor(element)
    );
}
 
Example #2
Source File: Coordinators.java    From Selenium-Foundation with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a 'wait' proxy that determines if the specified element reference has gone stale.
 *
 * @param element the element to wait for
 * @return 'false' if the element reference is still valid; otherwise 'true'
 */
public static Coordinator<Boolean> stalenessOf(final WebElement element) {
    return new Coordinator<Boolean>() {
        private final ExpectedCondition<Boolean> condition = conditionInitializer();

        // initializer for [condition] field
        private final ExpectedCondition<Boolean> conditionInitializer() {
            if (element instanceof WrapsElement) {
                return ExpectedConditions.stalenessOf(((WrapsElement) element).getWrappedElement());
            } else {
                return ExpectedConditions.stalenessOf(element);
            }
        }
        
        /**
         * {@inheritDoc}
         */
        @Override
        public Boolean apply(final SearchContext ignored) {
            return condition.apply(null);
        }
        
        /**
         * {@inheritDoc}
         */
        @Override
        public String toString() {
            return condition.toString();
        }
        
        /**
         * {@inheritDoc}
         */
        @Override
        public TimeoutException differentiateTimeout(TimeoutException e) {
            return new ElementStillFreshTimeoutException(e.getMessage(), e.getCause());
        }
    };
}
 
Example #3
Source File: TestBenchHelpers.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Assert that the two elements are equal.
 * <p>
 * Can be removed if https://dev.vaadin.com/ticket/18484 is fixed.
 *
 * @param expectedElement
 *            the expected element
 * @param actualElement
 *            the actual element
 */
protected static void assertEquals(WebElement expectedElement,
        WebElement actualElement) {
    WebElement unwrappedExpected = expectedElement;
    WebElement unwrappedActual = actualElement;
    while (unwrappedExpected instanceof WrapsElement) {
        unwrappedExpected = ((WrapsElement) unwrappedExpected)
                .getWrappedElement();
    }
    while (unwrappedActual instanceof WrapsElement) {
        unwrappedActual = ((WrapsElement) unwrappedActual)
                .getWrappedElement();
    }
    Assert.assertEquals(unwrappedExpected, unwrappedActual);
}
 
Example #4
Source File: ExtendedFieldDecorator.java    From carina with Apache License 2.0 5 votes vote down vote up
protected ExtendedWebElement proxyForLocator(ClassLoader loader, Field field, ElementLocator locator) {
    InvocationHandler handler = new LocatingElementHandler(locator);
    WebElement proxy = (WebElement) Proxy.newProxyInstance(loader, new Class[] { WebElement.class, WrapsElement.class, Locatable.class },
            handler);
    return new ExtendedWebElement(proxy, field.getName(),
            field.isAnnotationPresent(FindBy.class) || field.isAnnotationPresent(ExtendedFindBy.class)? new LocalizedAnnotations(field).buildBy() : null);
}
 
Example #5
Source File: ProxyFactory.java    From healenium-web with Apache License 2.0 4 votes vote down vote up
public static <T extends WebElement> T createWebElementProxy(ClassLoader loader, InvocationHandler handler) {
    Class<?>[] interfaces = new Class[]{WebElement.class, WrapsElement.class, Locatable.class};
    return (T) Proxy.newProxyInstance(loader, interfaces, handler);
}
 
Example #6
Source File: CurrentWebElementProvider.java    From bobcat with Apache License 2.0 4 votes vote down vote up
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);
}