use of com.seleniumtests.uipage.htmlelements.SelectList in project seleniumRobot by bhecquet.
the class PageObject method assertSelectedOption.
@GenericStep
public <T extends PageObject> T assertSelectedOption(String fieldName, String value) {
Element element = getElement(fieldName);
if (element instanceof SelectList) {
try {
WebElement selectedOption = ((SelectList) element).getFirstSelectedOption();
Assert.assertNotNull(selectedOption, "No selected option found");
Assert.assertEquals(selectedOption.getText(), value, "Selected option is not the expected one");
} catch (WebDriverException e) {
Assert.assertTrue(false, String.format(ERROR_ELEMENT_NOT_PRESENT, fieldName));
}
} else {
throw new ScenarioException(String.format("Element %s is not an SelectList subclass", fieldName));
}
return (T) this;
}
use of com.seleniumtests.uipage.htmlelements.SelectList in project seleniumRobot by bhecquet.
the class TestFrameElement method testSelectListInsideFrame.
@Test(groups = { "ut" })
public void testSelectListInsideFrame() throws Exception {
when(element.getTagName()).thenReturn("select");
FrameElement frame = new FrameElement("", By.id("frameId"));
SelectList el = new SelectList("", By.id("el"), frame);
el.getSelectedText();
verify(locator).frame(any(WebElement.class));
verify(locator, times(1)).defaultContent();
}
use of com.seleniumtests.uipage.htmlelements.SelectList in project seleniumRobot by bhecquet.
the class TestSelectList method testSelectByValues.
@Test(groups = { "ut" })
public void testSelectByValues() throws IOException {
when(option1.isSelected()).thenReturn(false);
when(option2.isSelected()).thenReturn(false);
when(element.getAttribute("multiple")).thenReturn("true");
SelectList select = new SelectList("", By.id("select"));
select.selectByValue("opti1", "opti2");
verify(option1).click();
verify(option2).click();
}
use of com.seleniumtests.uipage.htmlelements.SelectList 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);
}
use of com.seleniumtests.uipage.htmlelements.SelectList in project seleniumRobot by bhecquet.
the class TestSelectList method testIsMultipleNoAttribute.
@Test(groups = { "ut" })
public void testIsMultipleNoAttribute() throws IOException {
when(option1.isSelected()).thenReturn(true);
when(option2.isSelected()).thenReturn(false);
SelectList select = new SelectList("", By.id("select"));
Assert.assertFalse(select.isMultiple());
}
Aggregations