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) ? new LocalizedAnnotations(field).buildBy() : null, webDriver); }
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); }