本文整理汇总了Java中org.openqa.selenium.internal.WrapsElement类的典型用法代码示例。如果您正苦于以下问题:Java WrapsElement类的具体用法?Java WrapsElement怎么用?Java WrapsElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WrapsElement类属于org.openqa.selenium.internal包,在下文中一共展示了WrapsElement类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stalenessOf
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
/**
* 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);
}
}
@Override
public Boolean apply(SearchContext ignored) {
return condition.apply(null);
}
@Override
public String toString() {
return condition.toString();
}
};
}
示例2: unpackWebDriverFromSearchContext
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
/**
* This method extract an instance of {@link org.openqa.selenium.WebDriver} from the given
* {@link org.openqa.selenium.SearchContext}.
* @param searchContext is an instance of {@link org.openqa.selenium.SearchContext}
* It may be the instance of {@link org.openqa.selenium.WebDriver}
* or {@link org.openqa.selenium.WebElement} or some other user's
* extension/implementation.
* Note: if you want to use your own implementation then it should implement
* {@link org.openqa.selenium.internal.WrapsDriver} or
* {@link org.openqa.selenium.internal.WrapsElement}
* @return the instance of {@link org.openqa.selenium.WebDriver}.
* Note: if the given {@link org.openqa.selenium.SearchContext} is not
* {@link org.openqa.selenium.WebDriver} and it doesn't implement
* {@link org.openqa.selenium.internal.WrapsDriver} or
* {@link org.openqa.selenium.internal.WrapsElement} then this method returns
* null.
*
*/
public static WebDriver unpackWebDriverFromSearchContext(SearchContext searchContext) {
if (searchContext instanceof WebDriver) {
return (WebDriver) searchContext;
}
if (searchContext instanceof WrapsDriver) {
return unpackWebDriverFromSearchContext(
((WrapsDriver) searchContext).getWrappedDriver());
}
// Search context it is not only Webdriver. Webelement is search context
// too.
// RemoteWebElement and MobileElement implement WrapsDriver
if (searchContext instanceof WrapsElement) {
return unpackWebDriverFromSearchContext(
((WrapsElement) searchContext).getWrappedElement());
}
return null;
}
示例3: call
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
@Override
public Boolean call() throws Exception {
WebElement one = getElement();
WebElement two = getKnownElements().get(otherId);
// Unwrap the elements, if necessary
if (one instanceof WrapsElement) {
one = ((WrapsElement) one).getWrappedElement();
}
if (two instanceof KnownElements.ProxiedElement) {
two = ((KnownElements.ProxiedElement) two).getWrappedElement();
}
return one.equals(two);
}
示例4: apply
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
@Override
public WebElement apply(final WebElement element) {
return (WebElement) newProxyInstance(
getClass().getClassLoader(),
new Class[]{WebElement.class, WrapsElement.class, Locatable.class, HasIdentity.class},
invocationHandlerFor(element)
);
}
示例5: testGetWrappedElementOfTransformedElement
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
@Test(enabled = false)
public void testGetWrappedElementOfTransformedElement() {
final WebElement element = givenElement();
final WebElement transformedElement = transformer.apply(element);
assertThat(((WrapsElement) transformedElement).getWrappedElement(), sameInstance(element));
}
示例6: proxyForLocator
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
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);
}
示例7: extractInterfaces
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
protected Class<?>[] extractInterfaces(Object object) {
Set<Class<?>> allInterfaces = new HashSet<Class<?>>();
allInterfaces.add(WrapsDriver.class);
if (object instanceof WebElement) {
allInterfaces.add(WrapsElement.class);
}
extractInterfaces(allInterfaces, object.getClass());
return allInterfaces.toArray(new Class<?>[allInterfaces.size()]);
}
示例8: getWebElementFromFactory
import org.openqa.selenium.internal.WrapsElement; //导入依赖的package包/类
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);
}