final WebDriverException fooE = new WebDriverException("foo");
doThrow(fooE).when(wdSelect).getAllSelectedOptions();
FluentSelect select = new FluentSelect(wd, we, Context.singular(null, "dummy"), new Monitor.NULL(), false) {
@Override
protected Select getSelect() {
return wdSelect;
}
@Override
protected Void executeAndWrapReThrowIfNeeded(Execution execution, Internal.WebElementHolder currentElement, Context ctx, boolean expectedToBeThere) {
try {
execution.execute();
fail("should have barfed");
} catch (AssertionError e) {
throw e;
} catch (Throwable e) {
assertTrue(e == fooE);
}
throw new RuntimeException("bar");
}
};
try {
select.getAllSelectedOptions();
} catch (RuntimeException e) {
assertThat(e.getMessage(), equalTo("bar"));
}
verify(wdSelect).getAllSelectedOptions();