use of com.seleniumtests.uipage.htmlelements.select.StubSelect in project seleniumRobot by bhecquet.
the class SelectList method findElement.
@Override
protected void findElement() {
// set a default type so that use of selectImplementation can be done
selectImplementation = new StubSelect();
super.findElement(true);
// if we have a prefered implementation, use it
// search the right select list handler
implementationList = orderImplementations(getPreferedUiLibraries());
for (Class<? extends ISelectList> selectClass : implementationList) {
try {
ISelectList selectInstance = selectClass.getConstructor(WebElement.class, FrameElement.class).newInstance(getRealElementNoSearch(), frameElement);
if (selectInstance.isApplicable()) {
selectImplementation = selectInstance;
selectInstance.setDriver(getDriver());
break;
}
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
logger.error(String.format("Cannot use Select implementation %s: %s", selectClass.getName(), e.getMessage()));
}
}
if (selectImplementation instanceof StubSelect) {
throw new ScenarioException("Cannot find type of select " + getRealElementNoSearch().getTagName());
}
options = selectImplementation.getOptions();
multiple = selectImplementation.isMultipleWithoutFind();
}
use of com.seleniumtests.uipage.htmlelements.select.StubSelect in project seleniumRobot by bhecquet.
the class TestSelectList method testFindElementWrongType.
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testFindElementWrongType() throws IOException {
when(element.getTagName()).thenReturn("something");
SelectList select = new SelectList("", By.id("select"));
List<WebElement> options = select.getOptions();
Assert.assertTrue(select.getSelectImplementation() instanceof StubSelect);
}
Aggregations