本文整理汇总了Java中com.redhat.darcy.ui.DarcyException类的典型用法代码示例。如果您正苦于以下问题:Java DarcyException类的具体用法?Java DarcyException怎么用?Java DarcyException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DarcyException类属于com.redhat.darcy.ui包,在下文中一共展示了DarcyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setContext
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
/**
* Filters element or list fields, and if their associated objects implement
* {@link com.redhat.darcy.ui.api.HasElementContext}, calls
* {@link com.redhat.darcy.ui.api.HasElementContext#setContext(com.redhat.darcy.ui.api.ElementContext)}
* on those objects with the specified context.
*/
private void setContext(ElementContext context) {
fields.stream()
.filter(f -> HasElementContext.class.isAssignableFrom(f.getType())
|| Element.class.isAssignableFrom(f.getType())
|| List.class.isAssignableFrom(f.getType()))
// TODO: .filter(f -> f.getAnnotation(IndependentContext.class) == null)
.map(f -> {
try {
return f.get(view);
} catch (IllegalAccessException e) {
throw new DarcyException(String.format("Couldn't retrieve get object " +
"from field, %s, in view, %s", f, view), e);
}
})
.filter(o -> o instanceof HasElementContext)
.map(e -> (HasElementContext) e)
.forEach(e -> e.setContext(context));
}
示例2: shouldThrowDarcyExceptionWhenAnIOExceptionOccurs
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Test
public void shouldThrowDarcyExceptionWhenAnIOExceptionOccurs() throws IOException {
TargetedWebDriver driver = mock(TargetedWebDriver.class);
Browser browser = new WebDriverBrowser(driver,
new StubWebDriverParentContext(),
new StubWebDriverElementContext());
OutputStream outputStream = mock(OutputStream.class);
doThrow(new IOException()).when(outputStream).close();
try {
browser.takeScreenshot(outputStream);
fail("Expected DarcyException to be thrown");
} catch (Exception e) {
assertThat("Expected DarcyException to be thrown" ,
e.getClass(), equalTo(DarcyException.class));
}
verify(outputStream).close();
}
示例3: IdOfHandler
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
public IdOfHandler(Locator locator, Class type, Context context) {
this.context = context;
this.type = type;
original = locator.find(type, context);
if (!(original instanceof HasAttributes)) {
throw new DarcyException("Cannot lookup an id for a Findable if it does not implement "
+ "HasAttributes. Findable was, " + original);
}
}
示例4: assignContext
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
/**
* Sets fields annotated with {@link com.redhat.darcy.ui.annotations.Context @Context} with the
* specified context.
*/
private void assignContext(ElementContext context) {
fields.stream()
.filter(f -> f.getAnnotation(Context.class) != null)
.forEach(f -> {
try {
f.set(view, context);
} catch (IllegalAccessException | IllegalArgumentException e) {
throw new DarcyException("Couldn't assign context to field," + f, e);
}
});
}
示例5: fieldToObject
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
private Object fieldToObject(Field f) {
try {
return f.get(view);
} catch (IllegalAccessException e) {
throw new DarcyException("Couldn't analyze required fields.", e);
}
}
示例6: RequiredList
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public RequiredList(Field field, Object in) {
this.genericType = ReflectionUtil.getGenericTypeOfCollectionField(field);
this.bounds = new RequiredListBounds(field);
try {
this.list = (List<T>) field.get(in);
} catch (IllegalAccessException iae) {
throw new DarcyException("Couldn't access value of object", iae);
} catch (ClassCastException cce) {
throw new IllegalArgumentException("Can not cast field of object to List");
}
}
示例7: get
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
/**
* Returns something that can create real element implementations of the desired type (that is,
* an {@link com.redhat.darcy.webdriver.ElementConstructor}), given certain required inputs as
* defined in
* {@link ElementConstructor#newElement(com.redhat.darcy.webdriver.internal.ElementLookup, com.redhat.darcy.ui.api.ElementContext)}.
*/
@SuppressWarnings("unchecked")
public <E extends Element> ElementConstructor<E> get(Class<E> type) {
ElementConstructor<? extends Element> factory = classMap.get(type);
if (factory == null) {
throw new DarcyException("No element factory registered for " + type);
}
return (ElementConstructor<E>) factory;
}
示例8: findByNameOrId
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T findByNameOrId(Class<T> type, String nameOrId) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
WebDriverTarget newTarget = Frame.class.equals(type)
? WebDriverTargets.frame(myTarget, nameOrId)
: WebDriverTargets.window(nameOrId);
return (T) newBrowser(newTarget);
}
示例9: findAllByView
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> List<T> findAllByView(Class<T> type, View view) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
if (Frame.class.equals(type)) {
throw new DarcyException("Cannot find Frames by view. Unable to iterate through all "
+ "available frames.");
}
return (List<T>) new LazyList<>(new FoundByViewSupplier(view));
}
示例10: findByView
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T findByView(Class<T> type, View view) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
if (Frame.class.equals(type)) {
throw new DarcyException("Cannot find Frames by view. Unable to iterate through all "
+ "available frames.");
}
return (T) newBrowser(WebDriverTargets.withViewLoaded(view, this));
}
示例11: findAllByTitle
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> List<T> findAllByTitle(Class<T> type, String title) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
if (Frame.class.equals(type)) {
throw new DarcyException("Cannot find Frames by title. Unable to iterate through all "
+ "available frames.");
}
return (List<T>) new LazyList<>(new FoundByTitleSupplier(title));
}
示例12: findByTitle
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T findByTitle(Class<T> type, String title) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
if (Frame.class.equals(type)) {
throw new DarcyException("Cannot find Frames by title. Unable to iterate through all "
+ "available frames.");
}
return (T) newBrowser(WebDriverTargets.windowByTitle(title));
}
示例13: findAllByUrl
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Override
public <T> List<T> findAllByUrl(Class<T> type, Matcher<? super String> urlMatcher) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
if (Frame.class.equals(type)) {
throw new DarcyException("Cannot find Frames by url. Unable to iterate through all "
+ "available frames.");
}
return (List<T>) new LazyList<>(new FoundByUrlSupplier(urlMatcher));
}
示例14: findByUrl
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Override
public <T> T findByUrl(Class<T> type, Matcher<? super String> urlMatcher) {
if (!type.isAssignableFrom(WebDriverBrowser.class)) {
throw new DarcyException("Cannot find contexts of type: " + type);
}
if (Frame.class.equals(type)) {
throw new DarcyException("Cannot find Frames by url. Unable to iterate through all "
+ "available frames.");
}
return (T) newBrowser(WebDriverTargets.windowByUrl(urlMatcher));
}
示例15: findAllByNested
import com.redhat.darcy.ui.DarcyException; //导入依赖的package包/类
@Override
public <T> List<T> findAllByNested(Class<T> type, Element parent, Locator child) {
if (!(parent instanceof WebDriverElement)) {
throw new DarcyException("Parent element is not a WebDriverElement. Can only find " +
"by nested for fundamental UI element types found by darcy-webdriver.");
}
return newElementList(type, new NestedElementListLookup((WebDriverElement) parent, child));
}