final Select wdSelect = mock(Select.class);
final WebDriverException fooE = new WebDriverException("foo");
doThrow(fooE).when(wdSelect).selectByVisibleText("humphrey");
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.selectByVisibleText("humphrey");
} catch (RuntimeException e) {
assertThat(e.getMessage(), equalTo("bar"));
}
verify(wdSelect).selectByVisibleText("humphrey");