下面列出了怎么用org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler的API类实例代码及写法,或者点击链接到github查看源代码。
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);
}
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);
}